dimanche 19 novembre 2017

OOP - sharing data between classes

I have a class which keeps data and exposes methods to access that data: GameInfoList. A data is created based on 3 interfaces: A, B, C. I have also 2 interfaces to get a particular data: D, E.

I need to share GameInfoList between two classes, here is my approach:

//fills GameInfoList based on interfaces called by the different clients.
class GameInfo: public A, public B, public C
{
public:
    GameInfo(GameInfoList&)
    //A,B,C impl
private:
    GameInfoList& gameInfoList; 
};

//reads GameInfoList and allow to get a particular info.
class GameInfoProvider: public D, public E
{
public:
    GameInfoProvider(const GameInfoProvider&)
    //D,E impl
private:
    const GameInfoList& gameInfoList; 
};

Is there any design pattern which refers to the above scenario ? What do you think about my approach ?

Aucun commentaire:

Enregistrer un commentaire