Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

DLL Symbols Entity Framework

Started by ChaseRLewis Apr 16, 2014 at 5:20 PM 0 replies 1.8k views
Original Post
ChaseRLewis
ChaseRLewis

I'm not wanting to get full type information or anything crazy. I just am interested in creating a data driven design for my entities. Thing is I have NO idea how to get an enumeration of the DLL function names in Windows. I'm looking at stuff like DbgHelp and other stuff, but the documentation is pretty poor and I'm having a hard time figuring out how to enumerate it.

What I'm trying to do:



class GameComponent
{
protected:
virtual void XMLSave(XMLDocument& doc,XMLElement* parent) = 0;
virtual GameComponent* XMLLoad(XMLElement* node) = 0;
public:
virtual const int TypeID() = 0;
virtual const char* Name() = 0;
virtual void Update(){}
virtual void Initialize(){}
//etc...
};

Idea is a search through the symbol list when the engine initializes so that I can build a list of XMLSave, XMLLoad functions without having to hard code a static list of them. Also will allow me to be able to make additional dlls in the future and extend it.


class GameComponentFactory
{
private:
map<const char*,delegate<GameComponent*(XMLElement*)>> ComponentLoadMap;
public:
void Initialize(const char* dllPath);
Scene* LoadXMLFile(const char* path);
}

void GameObjectFactory::Initialize(const char* dllPath)
{
   /*
      How do you load the table?
   */
   vector<string> enumerations = LoadDLLExportTable(dllPath);

   /*
      Determine if class is derived from GameComponent ...
      if so add to the map functions that belong to the main game loop
      and xml load / save files.
      I've read papers that said they've done this ... I just have no clue how.
   */
}

Scene* GameComponentFactory::LoadXMLFile(const char* path)
{
/*
   Psuedo-code would need to be much more safe
*/
   XMLDocument doc;
   doc.Open(path);
Scene* scene = ResourceManager::NewScene();
for(auto obj = doc->FirstChildElement();obj;obj->NextSiblingElement())
{
   GameObject* go = new GameObject(obj->Name());
   for(auto component = obj->FirstChildElement();component;component->NextSiblingElement())
    {
       go->AddComponent(ComponentLoadMap[component->Name()](component));
    }
    scene->AddGameObject(go);
}
  return scene;
}

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.