PixelLightAPI  .
SceneQuery.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: SceneQuery.h                                   *
00003  *
00004  *  Copyright (C) 2002-2011 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLSCENE_SCENEQUERY_H__
00024 #define __PLSCENE_SCENEQUERY_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLCore/Base/Object.h>
00032 #include <PLCore/Base/Event/Event.h>
00033 #include <PLCore/Container/Element.h>
00034 #include <PLCore/Container/ElementHandler.h>
00035 #include <PLCore/Container/ElementManager.h>
00036 #include "PLScene/PLScene.h"
00037 
00038 
00039 //[-------------------------------------------------------]
00040 //[ Namespace                                             ]
00041 //[-------------------------------------------------------]
00042 namespace PLScene {
00043 
00044 
00045 //[-------------------------------------------------------]
00046 //[ Forward declarations                                  ]
00047 //[-------------------------------------------------------]
00048 class SceneNode;
00049 class SceneContext;
00050 class SceneContainer;
00051 
00052 
00053 //[-------------------------------------------------------]
00054 //[ Classes                                               ]
00055 //[-------------------------------------------------------]
00056 /**
00057 *  @brief
00058 *    Abstract scene query class
00059 *
00060 *  @remarks
00061 *    The scene query is operating on a scene container. For instance there
00062 *    can be a query to perform volume checks against the scene or a query
00063 *    rendering the scene. This process can be quite efficient if the scene
00064 *    container provides a good scene hierarchy. Events will inform about the results.
00065 *
00066 *  @note
00067 *    - Derived classes should use a 'SQ'-prefix (example: SQLine)
00068 */
00069 class SceneQuery : public PLCore::Object, public PLCore::Element<SceneQuery> {
00070 
00071 
00072     //[-------------------------------------------------------]
00073     //[ Friends                                               ]
00074     //[-------------------------------------------------------]
00075     friend class SceneContainer;
00076     friend class PLCore::ElementManager<SceneQuery>;
00077 
00078 
00079     //[-------------------------------------------------------]
00080     //[ Public definitions                                    ]
00081     //[-------------------------------------------------------]
00082     public:
00083         /**
00084         *  @brief
00085         *   Flags
00086         */
00087         enum EFlags {
00088             Recursive = 1<<0,   /**< Take sub scene containers into account */
00089             StopQuery = 1<<1    /**< Stop the currently running query (removed within PerformQuery() on start automatically) */
00090         };
00091 
00092 
00093     //[-------------------------------------------------------]
00094     //[ RTTI interface                                        ]
00095     //[-------------------------------------------------------]
00096     pl_class(PLS_RTTI_EXPORT, SceneQuery, "PLScene", PLCore::Object, "Abstract scene query class")
00097         // Signals
00098         pl_signal_2(SignalSceneNode,    SceneQuery&,    SceneNode&, "A scene node was 'touched' during the query. Event causing scene query and found scene node as parameters.",   "")
00099     pl_class_end
00100 
00101 
00102     //[-------------------------------------------------------]
00103     //[ Public functions                                      ]
00104     //[-------------------------------------------------------]
00105     public:
00106         /**
00107         *  @brief
00108         *    Returns the scene context the scene query is in
00109         *
00110         *  @return
00111         *    The scene context the scene query is in, can but shouldn't be a null pointer
00112         */
00113         PLS_API SceneContext *GetSceneContext() const;
00114 
00115         /**
00116         *  @brief
00117         *    Returns the scene container this query operates on
00118         *
00119         *  @return
00120         *    The scene container this query operates on
00121         */
00122         inline SceneContainer &GetSceneContainer() const;
00123 
00124         /**
00125         *  @brief
00126         *    Returns the flags
00127         *
00128         *  @return
00129         *    Flags (see EFlags)
00130         */
00131         inline PLCore::uint32 GetFlags() const;
00132 
00133         /**
00134         *  @brief
00135         *    Sets the flags
00136         *
00137         *  @param[in] nFlags
00138         *    Flags (see EFlags)
00139         */
00140         inline void SetFlags(PLCore::uint32 nFlags = Recursive);
00141 
00142         /**
00143         *  @brief
00144         *    Stops the currently running query
00145         */
00146         inline void Stop();
00147 
00148 
00149     //[-------------------------------------------------------]
00150     //[ Public virtual SceneQuery functions                   ]
00151     //[-------------------------------------------------------]
00152     public:
00153         /**
00154         *  @brief
00155         *    Performs the query
00156         *
00157         *  @note
00158         *    - Before you start the query you have to do some settings within
00159         *      the derived query classes first. (for instance setting the query
00160         *      volume)
00161         *
00162         *  @return
00163         *    'true' if the query was cancelled by the user, else 'false'
00164         */
00165         virtual bool PerformQuery() = 0;
00166 
00167 
00168     //[-------------------------------------------------------]
00169     //[ Protected functions                                   ]
00170     //[-------------------------------------------------------]
00171     protected:
00172         /**
00173         *  @brief
00174         *    Constructor
00175         */
00176         PLS_API SceneQuery();
00177 
00178         /**
00179         *  @brief
00180         *    Destructor
00181         */
00182         PLS_API virtual ~SceneQuery();
00183 
00184 
00185     //[-------------------------------------------------------]
00186     //[ Protected data                                        ]
00187     //[-------------------------------------------------------]
00188     protected:
00189         PLCore::uint32 m_nFlags;    /**< Flags (see EFlags) */
00190 
00191 
00192     //[-------------------------------------------------------]
00193     //[ Private data                                          ]
00194     //[-------------------------------------------------------]
00195     private:
00196         SceneContainer *m_pSceneContainer;  /**< Scene container this query operates on, NEVER a null pointer */
00197 
00198 
00199 };
00200 
00201 
00202 //[-------------------------------------------------------]
00203 //[ Namespace                                             ]
00204 //[-------------------------------------------------------]
00205 } // PLScene
00206 
00207 
00208 //[-------------------------------------------------------]
00209 //[ Implementation                                        ]
00210 //[-------------------------------------------------------]
00211 #include "SceneQuery.inl"
00212 
00213 
00214 #endif // __PLSCENE_SCENEQUERY_H__


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:51:01
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported