I'm trying to make an efficient "entity system" in C++, I've read a lot of blog/articles/documentation on the Internet to get lot of information but I've got some questions again.
I've find two interesting subjects:
- Data-driven system
- Entity component system
For me, the two systems look very similar.
So, I've found this example by Adam Smith: https://stackoverflow.com/a/2021868
I need to have a flexible system like this:
// Abstract class
class Component
{
     // data here
}
// exemple
class Car : public Component
{
    // Data here
}
// Entity with components
class Entity
{
   std::vector<Component*> components;
}
So, if my entity have the followings components: Car, Transform, Sprite, did my components array will had linear data like data-driven system?
Now, I have Systems:
class System 
{
     virtual void init();
     virtual void clear();
     virtual void update();
     std::unordered_map< const char*, Entity*> entities;
}
class RendererSystem : public System
{
    // Methods's definition (init, clear, …).
    void update()
    {
       for( entity, … )
       {
           Sprite* s = entity->getComponent('sprite');
           ...
       }
    }
}
- I've read that virtual functions are bad, it's bad in that case?
- Get component need a static_cast, that's bad?
- In data-driven system, I saw pointer everywhere, si where is the "original" variables, I need to put new everywhere or I will have a class with an array of same data?
- Did I make this right?
All this points look "blur" in my mind.
 
     
    