89 lines
2.4 KiB
C++
89 lines
2.4 KiB
C++
/** 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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|