I've been working on an engine I started working on awhile ago, but abandoned due to lack of interest, and I'm currently re-writing the majority of it due to poor design, and I was wondering if I was going about a component based system the right way. Basically currently I have several manager classes, each of the also have a representative component class that contains a static instance of the manager as well any functions that would be commonly used among any class inheriting from that class, but it just feels too much like a singleton to me, and I want to make sure that it's following the object oriented design theory before I re-write everything to work around that system.
An example of what I'm talking about if I didn't clearly explain it,
BlobOfFailure wrote:I've been working on an engine I started working on awhile ago, but abandoned due to lack of interest, and I'm currently re-writing the majority of it due to poor design, and I was wondering if I was going about a component based system the right way. Basically currently I have several manager classes, each of the also have a representative component class that contains a static instance of the manager as well any functions that would be commonly used among any class inheriting from that class, but it just feels too much like a singleton to me, and I want to make sure that it's following the object oriented design theory before I re-write everything to work around that system.
An example of what I'm talking about if I didn't clearly explain it,
class Player: public Sprite
{
Player();
//Contents of player class
};
I'm not quite sure i understand what you are trying to do. What are the components using the static instance of the manager for. Also, if the manager is going to manage components wouldn't using pointers/references for the components be better, since you want the changes some manager(say the physics manager) makes to a component to reflect in the other managers(say the Render manager).
Sorry about how confusing my question was, the static instances of the manager were basically being used as a singleton and my question was, and I was asking was that proper. Yes it should be a pointer or reference, but I was just trying to explain how I was going about my horrid system of managers and components, but I realized that I was basically using singletons and messy code, and learned the proper alternative. Basically I had no idea how to go about a component based system and thought that each class should be able to add it's self to the manager...