first commit
This commit is contained in:
20
lib/EventManager/trunk/source/DateTime.cpp
Normal file
20
lib/EventManager/trunk/source/DateTime.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
/** Includes ***********************/
|
||||
#include "EventManager/DateTime.h"
|
||||
|
||||
/** Macros *************************/
|
||||
|
||||
/** Variables **********************/
|
||||
|
||||
/** Forward Declarations ***********/
|
||||
|
||||
/** Implementations ****************/
|
||||
namespace CKG
|
||||
{
|
||||
namespace Lib
|
||||
{
|
||||
namespace EventManager
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
72
lib/EventManager/trunk/source/Event.cpp
Normal file
72
lib/EventManager/trunk/source/Event.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
/** Includes ***********************/
|
||||
#include "EventManager/Event.h"
|
||||
|
||||
/** Macros *************************/
|
||||
|
||||
/** Variables **********************/
|
||||
|
||||
/** Forward Declarations ***********/
|
||||
|
||||
/** Implementations ****************/
|
||||
namespace CKG
|
||||
{
|
||||
namespace Lib
|
||||
{
|
||||
namespace EventManager
|
||||
{
|
||||
/*!
|
||||
\brief Default Event constructor
|
||||
*/
|
||||
Event::Event(const Char *eventInfo, const int numTriggers, const DateTime *triggers)
|
||||
: mEventInformation(eventInfo)
|
||||
{
|
||||
mTriggers.reserve(numTriggers);
|
||||
|
||||
for (int i = 0; i < numTriggers; i++)
|
||||
{
|
||||
mTriggers.push_back(triggers[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Destroys an event
|
||||
*/
|
||||
Event::~Event()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Sets the event information
|
||||
|
||||
\param eventInfo - Information for the event
|
||||
\return - void.
|
||||
*/
|
||||
void Event::SetEventInformation(const Char *eventInfo)
|
||||
{
|
||||
mEventInformation = stlport::string(eventInfo);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Should this event be triggered
|
||||
|
||||
\param currentDateTime - Time to compare against
|
||||
\return - True if the event should trigger
|
||||
*/
|
||||
bool Event::ShouldTrigger(const DateTime ¤tDateTime) const
|
||||
{
|
||||
TriggerList::const_iterator iter = mTriggers.begin(), end = mTriggers.end();
|
||||
|
||||
for (; iter != end; ++iter)
|
||||
{
|
||||
if (currentDateTime.GetTime() < iter->GetTime())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/** Includes ***********************/
|
||||
#include <stdio.h>
|
||||
#include "vector"
|
||||
|
||||
#include "EventManager/EventLoaders/EventLoaderSimple.h"
|
||||
|
||||
/** Macros *************************/
|
||||
|
||||
/** Variables **********************/
|
||||
|
||||
/** Forward Declarations ***********/
|
||||
|
||||
/** Implementations ****************/
|
||||
namespace CKG
|
||||
{
|
||||
namespace Lib
|
||||
{
|
||||
namespace EventManager
|
||||
{
|
||||
namespace EventLoaders
|
||||
{
|
||||
EventLoaderSimple::EventLoaderSimple()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
EventLoaderSimple::~EventLoaderSimple()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
bool EventLoaderSimple::IsFileValid(const FileName fileName)
|
||||
{
|
||||
FILE *fp = fopen(fileName, "r");
|
||||
|
||||
if (fp != NULL)
|
||||
{
|
||||
fclose(fp);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Loads an event in the simple format described below
|
||||
|
||||
\param fileName - file to load
|
||||
\param outNumEvents - [out] Number of events loaded
|
||||
\param outEvents - [out] Array of loaded events
|
||||
\return - void.
|
||||
|
||||
File Format:
|
||||
E:<value>:<description>
|
||||
T:<trigger, in seconds>:<TriggerDescription>
|
||||
<1 .. N triggers>
|
||||
<1 .. N Events>
|
||||
*/
|
||||
void EventLoaderSimple::LoadEvents(const FileName fileName, int *outNumEvents, Event **outEvents)
|
||||
{
|
||||
// Protect the function call
|
||||
if (!outNumEvents || !outEvents)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Open the file
|
||||
FILE *fp = fopen(fileName, "r");
|
||||
|
||||
if (fp != NULL)
|
||||
{
|
||||
fclose(fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
outNumEvents = NULL;
|
||||
outEvents = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
34
lib/EventManager/trunk/source/EventManager.cpp
Normal file
34
lib/EventManager/trunk/source/EventManager.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/** Includes ***********************/
|
||||
#include "EventManager/EventManager.h"
|
||||
|
||||
/** Macros *************************/
|
||||
|
||||
/** Variables **********************/
|
||||
|
||||
/** Forward Declarations ***********/
|
||||
|
||||
/** Implementations ****************/
|
||||
namespace CKG
|
||||
{
|
||||
namespace Lib
|
||||
{
|
||||
namespace EventManager
|
||||
{
|
||||
/*!
|
||||
\brief Default EventManager constructor
|
||||
*/
|
||||
EventManager::EventManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Destructs the Event Manager
|
||||
*/
|
||||
EventManager::~EventManager()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user