Browse Source

- Fixing the event manager
- Fixing the doxigen file

Panagiotis Christopoulos Charitos 13 years ago
parent
commit
be3a4e282d

+ 2 - 2
docs/doxyfile

@@ -590,7 +590,7 @@ WARN_LOGFILE           =
 # directories like "/usr/src/myproject". Separate the files or directories 
 # with spaces.
 
-INPUT                  = @CMAKE_CURRENT_SOURCE_DIR@/anki
+INPUT                  = @CMAKE_CURRENT_SOURCE_DIR@/include @CMAKE_CURRENT_SOURCE_DIR@/src
 
 # This tag can be used to specify the character encoding of the source files 
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is 
@@ -1328,7 +1328,7 @@ SEARCH_INCLUDES        = YES
 # contain include files that are not input files but should be processed by 
 # the preprocessor.
 
-INCLUDE_PATH           = @CMAKE_CURRENT_SOURCE_DIR@/anki
+INCLUDE_PATH           = @CMAKE_CURRENT_SOURCE_DIR@/include
 
 # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
 # patterns (like *.h and *.hpp) to filter out the header-files in the 

+ 9 - 15
include/anki/event/Event.h

@@ -1,25 +1,21 @@
 #ifndef ANKI_EVENT_EVENT_H
 #define ANKI_EVENT_EVENT_H
 
-#include "anki/util/StdTypes.h"
-
-
 namespace anki {
 
-
-/// The event type enum
-enum EventType
-{
-	SCENE_COLOR,
-	MAIN_RENDERER_PPS_HDR,
-	EVENT_TYPES_NUM
-};
-
-
 /// Abstract class for all events. All Event derived classes should be copy-able
+/// In order to recycle the events and save the mallocs
 class Event
 {
 public:
+	/// The event type enum
+	enum EventType
+	{
+		ET_SCENE_COLOR,
+		ET_MAIN_RENDERER_PPS_HDR,
+		ET_COUNT
+	};
+
 	/// Constructor
 	Event(EventType type, float startTime, float duration);
 
@@ -80,8 +76,6 @@ private:
 	float duration; ///< The duration of the event
 };
 
-
 } // end namespace
 
-
 #endif

+ 26 - 11
include/anki/event/EventManager.h

@@ -2,12 +2,11 @@
 #define ANKI_EVENT_MANAGER_H
 
 #include "anki/event/Event.h"
+#include "anki/util/Singleton.h"
 #include <boost/ptr_container/ptr_deque.hpp>
 
-
 namespace anki {
 
-
 /// This manager creates the events ands keeps tracks of them
 class EventManager
 {
@@ -15,31 +14,47 @@ public:
 	typedef boost::ptr_deque<Event> EventsContainer;
 
 	/// Create a new event
-	template<typename EventType>
-	EventType& createEvent(const EventType& event);
+	template<typename EventClass>
+	EventClass& createEvent(const EventClass& event);
 
 	/// Update
 	void updateAllEvents(float prevUpdateTime, float crntTime);
 
 private:
-	enum
-	{
-		MAX_EVENTS_SIZE = 1000
-	};
+	static const size_t MAX_EVENTS_SIZE = 1000;
 
 	EventsContainer events;
 	float prevUpdateTime;
 	float crntTime;
 
 	/// Find a dead event of a certain type
-	EventsContainer::iterator findADeadEvent(EventType type);
+	EventsContainer::iterator findADeadEvent(Event::EventType type);
 };
 
+/// The singleton EventManager
+typedef Singleton<EventManager> EventManagerSingleton;
 
-} // end namespace
+//==============================================================================
+template<typename EventClass>
+EventClass& EventManager::createEvent(const EventClass& event)
+{
+	EventsContainer::iterator it = findADeadEvent(event.getEventType());
+	EventClass* ev;
 
+	if(it == events.end()) // No dead event found
+	{
+		ev = new EventClass(event);
+		events.push_back(ev);
+	}
+	else // Re-use a dead event
+	{
+		ev = &static_cast<EventClass&>(*it);
+		*ev = event;
+	}
 
-#include "anki/event/EventManager.inl.h"
+	return *ev;
+}
 
+} // end namespace
 
 #endif

+ 0 - 31
include/anki/event/EventManager.inl.h

@@ -1,31 +0,0 @@
-#include "anki/event/EventManager.h"
-
-
-namespace anki {
-
-
-//==============================================================================
-//  createEvent                                                                =
-//==============================================================================
-template<typename EventType>
-EventType& EventManager::createEvent(const EventType& event)
-{
-	EventsContainer::iterator it = findADeadEvent(event.getEventType());
-	EventType* ev;
-
-	if(it == events.end()) // No dead event found
-	{
-		ev = new EventType(event);
-		events.push_back(ev);
-	}
-	else // Re-use a dead event
-	{
-		ev = &static_cast<EventType&>(*it);
-		*ev = event;
-	}
-
-	return *ev;
-}
-
-
-} // end namespace

+ 3 - 6
include/anki/event/MainRendererPpsHdrEvent.h

@@ -2,18 +2,17 @@
 #define ANKI_EVENT_MAIN_RENDERER_PPS_HDR_EVENT_H
 
 #include "anki/event/Event.h"
-
+#include <cstdint>
 
 namespace anki {
 
-
 /// Change the HDR properties
 class MainRendererPpsHdrEvent: public Event
 {
 public:
 	/// Constructor
 	MainRendererPpsHdrEvent(float startTime, float duration,
-		float exposure, uint blurringIterationsNum, float blurringDist);
+		float exposure, uint32_t blurringIterationsNum, float blurringDist);
 
 	/// Copy constructor
 	MainRendererPpsHdrEvent(const MainRendererPpsHdrEvent& b);
@@ -25,7 +24,7 @@ private:
 	struct Data
 	{
 		float exposure; ///< @see Hdr::exposure
-		uint blurringIterationsNum; ///< @see Hdr::blurringIterationsNum
+		uint32_t blurringIterationsNum; ///< @see Hdr::blurringIterationsNum
 		float blurringDist; ///< @see Hdr::blurringDist
 	};
 
@@ -36,8 +35,6 @@ private:
 	void updateSp(float prevUpdateTime, float crntTime);
 };
 
-
 } // end namespace
 
-
 #endif

+ 0 - 4
include/anki/event/SceneColorEvent.h

@@ -4,10 +4,8 @@
 #include "anki/event/Event.h"
 #include "anki/math/Math.h"
 
-
 namespace anki {
 
-
 /// Change the scene color
 class SceneColorEvent: public Event
 {
@@ -30,8 +28,6 @@ private:
 	void updateSp(float prevUpdateTime, float crntTime);
 };
 
-
 } // end namespace
 
-
 #endif

+ 2 - 4
include/anki/gl/Fbo.h

@@ -14,10 +14,8 @@ class Texture;
 /// @addtogroup gl
 /// @{
 
-/// Frame buffer object
-///
-/// The class is actually a wrapper to avoid common mistakes. It only supports
-/// binding at both draw and read targets
+/// Frame buffer object. The class is actually a wrapper to avoid common 
+/// mistakes. It only supports binding at both draw and read targets
 class Fbo
 {
 public:

+ 0 - 5
include/anki/renderer/Bl.h

@@ -6,13 +6,10 @@
 #include "anki/resource/Resource.h"
 #include "anki/gl/Fbo.h"
 
-
 namespace anki {
 
-
 class ShaderProgramResource;
 
-
 /// Blurring rendering pass
 class Bl: public SwitchableRenderingPass
 {
@@ -72,8 +69,6 @@ private:
 	void runSideBlur();
 };
 
-
 } // end namespace
 
-
 #endif

+ 1 - 1
include/anki/renderer/MainRenderer.h

@@ -78,7 +78,7 @@ class MainRenderer: public Renderer
 		/// @name Profiling stuff
 		/// @{
 		double dbgTime;
-		boost::scoped_ptr<TimeQuery> dbgTq;
+		boost::scoped_ptr<Query> dbgTq;
 		/// @}
 
 		ShaderProgramResourcePointer sProg; ///< Final pass' shader program

+ 1 - 1
include/anki/renderer/Renderer.h

@@ -14,7 +14,7 @@
 #include "anki/renderer/Bs.h"
 #include "anki/renderer/Dbg.h"
 #include "anki/gl/GlException.h"
-#include "anki/gl/GlStateMachine.h"
+#include "anki/gl/GlState.h"
 #include "anki/gl/Query.h"
 #include "anki/renderer/Drawer.h"
 #include <boost/scoped_ptr.hpp>

+ 0 - 11
src/event/Event.cpp

@@ -1,20 +1,13 @@
 #include "anki/event/Event.h"
 #include "anki/util/Assert.h"
 
-
 namespace anki {
 
-
-//==============================================================================
-// Constructor                                                                 =
 //==============================================================================
 Event::Event(EventType type_, float startTime_, float duration_)
 	: type(type_), startTime(startTime_), duration(duration_)
 {}
 
-
-//==============================================================================
-// operator=                                                                   =
 //==============================================================================
 Event& Event::operator=(const Event& b)
 {
@@ -24,9 +17,6 @@ Event& Event::operator=(const Event& b)
 	return *this;
 }
 
-
-//==============================================================================
-// update                                                                      =
 //==============================================================================
 void Event::update(float prevUpdateTime, float crntTime)
 {
@@ -39,5 +29,4 @@ void Event::update(float prevUpdateTime, float crntTime)
 	}
 }
 
-
 } // end namespace

+ 3 - 12
src/event/EventManager.cpp

@@ -1,19 +1,14 @@
 #include "anki/event/EventManager.h"
-#include <boost/foreach.hpp>
-
 
 namespace anki {
 
-
-//==============================================================================
-// updateAllEvents                                                             =
 //==============================================================================
 void EventManager::updateAllEvents(float prevUpdateTime_, float crntTime_)
 {
 	prevUpdateTime = prevUpdateTime_;
 	crntTime = crntTime_;
 
-	BOOST_FOREACH(Event& event, events)
+	for(Event& event : events)
 	{
 		if(!event.isDead(crntTime))
 		{
@@ -22,12 +17,9 @@ void EventManager::updateAllEvents(float prevUpdateTime_, float crntTime_)
 	}
 }
 
-
-//==============================================================================
-// findADeadEvent                                                              =
 //==============================================================================
-EventManager::EventsContainer::iterator EventManager::findADeadEvent(
-	EventType type)
+EventManager::EventsContainer::iterator EventManager::
+	findADeadEvent(Event::EventType type)
 {
 	EventsContainer::iterator it = events.begin();
 
@@ -43,5 +35,4 @@ EventManager::EventsContainer::iterator EventManager::findADeadEvent(
 	return it;
 }
 
-
 } // end namespace

+ 2 - 16
src/event/MainRendererPpsHdrEvent.cpp

@@ -2,19 +2,15 @@
 #include "anki/renderer/MainRenderer.h"
 #include "anki/core/Globals.h"
 
-
 namespace anki {
 
-
-//==============================================================================
-// Constructor                                                                 =
 //==============================================================================
 MainRendererPpsHdrEvent::MainRendererPpsHdrEvent(float startTime,
 	float duration,
 	float exposure_,
 	uint blurringIterationsNum_,
 	float blurringDist_)
-	: Event(MAIN_RENDERER_PPS_HDR, startTime, duration)
+	: Event(ET_MAIN_RENDERER_PPS_HDR, startTime, duration)
 {
 	finalData.exposure = exposure_;
 	finalData.blurringIterationsNum = blurringIterationsNum_;
@@ -27,20 +23,14 @@ MainRendererPpsHdrEvent::MainRendererPpsHdrEvent(float startTime,
 	originalData.blurringDist = hdr.getBlurringDistance();
 }
 
-
-//==============================================================================
-// Copy constructor                                                            =
 //==============================================================================
 MainRendererPpsHdrEvent::MainRendererPpsHdrEvent(
 	const MainRendererPpsHdrEvent& b)
-	: Event(MAIN_RENDERER_PPS_HDR, 0.0, 0.0)
+	: Event(ET_MAIN_RENDERER_PPS_HDR, 0.0, 0.0)
 {
 	*this = b;
 }
 
-
-//==============================================================================
-// operator=                                                                   =
 //==============================================================================
 MainRendererPpsHdrEvent& MainRendererPpsHdrEvent::operator=(
 	const MainRendererPpsHdrEvent& b)
@@ -51,9 +41,6 @@ MainRendererPpsHdrEvent& MainRendererPpsHdrEvent::operator=(
 	return *this;
 }
 
-
-//==============================================================================
-// updateSp                                                                    =
 //==============================================================================
 void MainRendererPpsHdrEvent::updateSp(float /*prevUpdateTime*/, float crntTime)
 {
@@ -72,5 +59,4 @@ void MainRendererPpsHdrEvent::updateSp(float /*prevUpdateTime*/, float crntTime)
 		finalData.blurringDist, dp));
 }
 
-
 } // end namespace

+ 2 - 15
src/event/SceneColorEvent.cpp

@@ -3,33 +3,23 @@
 #include "anki/core/Globals.h"
 #include "anki/core/Logger.h"
 
-
 namespace anki {
 
-
-//==============================================================================
-// Constructor                                                                 =
 //==============================================================================
 SceneColorEvent::SceneColorEvent(float startTime, float duration,
 	const Vec3& finalColor_)
-	: Event(SCENE_COLOR, startTime, duration), finalColor(finalColor_)
+	: Event(ET_SCENE_COLOR, startTime, duration), finalColor(finalColor_)
 {
 	originalColor = SceneSingleton::get().getAmbientColor();
 }
 
-
-//==============================================================================
-// Constructor copy                                                            =
 //==============================================================================
 SceneColorEvent::SceneColorEvent(const SceneColorEvent& b)
-	: Event(SCENE_COLOR, 0.0, 0.0)
+	: Event(ET_SCENE_COLOR, 0.0, 0.0)
 {
 	*this = b;
 }
 
-
-//==============================================================================
-// operator=                                                                   =
 //==============================================================================
 SceneColorEvent& SceneColorEvent::operator=(const SceneColorEvent& b)
 {
@@ -39,9 +29,6 @@ SceneColorEvent& SceneColorEvent::operator=(const SceneColorEvent& b)
 	return *this;
 }
 
-
-//==============================================================================
-// updateSp                                                                    =
 //==============================================================================
 void SceneColorEvent::updateSp(float /*prevUpdateTime*/, float crntTime)
 {

+ 0 - 6
src/renderer/Bl.cpp

@@ -3,10 +3,8 @@
 #include "anki/renderer/Renderer.h"
 #include "anki/resource/ShaderProgramResource.h"
 
-
 namespace anki {
 
-
 //==============================================================================
 void Bl::init(const RendererInitializer& initializer)
 {
@@ -77,7 +75,6 @@ void Bl::init(const RendererInitializer& initializer)
 	sideBlurSProg.load("shaders/PpsSideBlur.glsl");
 }
 
-
 //==============================================================================
 void Bl::runSideBlur()
 {
@@ -99,7 +96,6 @@ void Bl::runSideBlur()
 	r->drawQuad();
 }
 
-
 //==============================================================================
 void Bl::runBlur()
 {
@@ -134,7 +130,6 @@ void Bl::runBlur()
 	}
 }
 
-
 //==============================================================================
 void Bl::run()
 {
@@ -147,5 +142,4 @@ void Bl::run()
 	runBlur();
 }
 
-
 } // end namespace