updated todo.txt;

added some files as .pdf, too
This commit is contained in:
sicarius 2007-02-04 21:38:03 +00:00
parent 5843f35538
commit 7370f9ab1e
12 changed files with 57 additions and 53 deletions

View file

@ -6,4 +6,4 @@ namespace hardware
};
#endif
#endif

View file

@ -88,4 +88,4 @@ enum IOModuleNames
IO_END = IO_SENSOR_END,
};
#endif
#endif

View file

@ -16,4 +16,4 @@ public:
}
};
#endif
#endif

View file

@ -26,4 +26,4 @@ public:
};
#endif
#endif

View file

@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
int main()
{
@ -44,4 +44,4 @@ int main()
//Cleanup
delete localRobot;
localRobot = NULL;
}
}

View file

@ -1,24 +1,31 @@
#include "robot.h"
#include "robot.h"
//-----------------------------------------------------------------------------
Robot::Robot()
{
memset(modules, NULL, sizeof(modules));
}
//-----------------------------------------------------------------------------
Robot::~Robot()
{
while(!modules.empty())
{
moduleMap::iterator iter = modules.begin();
delete iter->second;
modules.erase(iter);
{
for(uint8 i = 0; i < IO_END; i++)
{
if(!modules[i]) continue;
delete modules[i];
modules[i] = NULL;
}
}
//-----------------------------------------------------------------------------
bool Robot::AddModule(IO_Module* newModule)
{
moduleMap::iterator itr = modules.find(newModule->GetId());
if(itr != modules.end())
{
if(modules[newModule->GetId()])
return false;
modules[newModule->GetId()] = newModule;
modules[newModule->GetId()] = newModule;
return true;
}
@ -34,4 +41,4 @@ void Robot::Update()
//insert code here
}
//--- EOF ---
//--- EOF ---

View file

@ -9,32 +9,29 @@ class Engine;
class Robot
{
public:
public:
Robot();
~Robot();
private:
typedef hash_map<uint32, IO_Module*> moduleMap;
moduleMap modules;
IO_Module* modules[IO_END];
public:
bool AddModule(IO_Module* newModule);
template <class T> T* GetModule(uint32 moduleId)
{
moduleMap::const_iterator itr = modules.find(moduleId);
if(itr == modules.end())
return NULL;
else
return ((T*)itr->second);
template <class T> T* GetModule(uint8 moduleId)
{
return ((T*)modules[moduleId]);
}
bool RemoveModule(uint32 moduleId)
{
moduleMap::iterator itr = modules.find(moduleId);
if(itr == modules.end())
return false;
modules.erase(itr);
bool RemoveModule(uint8 moduleId)
{
if(!modules[moduleId])
return false;
delete modules[moduleId];
modules[moduleId] = NULL;
return true;
}
@ -43,4 +40,4 @@ public:
void Update();
};
#endif
#endif

View file

@ -26,4 +26,4 @@ public:
}
};
#endif
#endif

View file

@ -1,12 +1,10 @@
#include <iostream>
#include <stdlib.h>
#include <string>
#include <hash_map>
using namespace std;
#include "defines.h"
#include "defines.h"
#include "tools.h"
#include "io_module.h"
#include "sensor.h"
#include "engine.h"
#include "robot.h"
#include "robot.h"