Boost logo

Boost Users :

From: Ramesh (rramesh1_at_[hidden])
Date: 2008-07-22 20:11:46


Hi,

I am a newbie to C++ & boost, I have questions on choosing the right boost
container for my requirement.

*A base class :*

class Player {

    protected:
        std::string PlayerId; // real, winamp, Windows media, vlc,
divx
        long capMask // capability mask
    public:
        Player(std::string param_Id, long param_Mask) {
            Id = param_Id;
            capMask = param_Mask;
        }
};

*Two derived classes:*

*Derived Class I:*

class Port_Player:public Player {
    protected:
        bool IsTouchScreen; // True if touch screen based
    public:
        Port_Player(std::string param_Id, long param_Mask, bool TS)
                :Player(param_Id, param_Mask) {
            IsTouchScreen = TS;
        }
}

*Dervied Class II:*

class Non_Port_Player:public Player {
    protected:
        long Browser; // Supported by firefox, IE etc
    public:
        Non_Port_Player(std::string param_Id, long param_Mask, long
pBrowser)
                :Player(param_Id, param_Mask) {
            Browser = pBrowser;
        }
}

Questions I have:

1) As I would create objects of either Derived Class I or Derived Class II
(which would be known to be only at runtime) and I need to add pointers to
these objects in a container, I would like to know which container would
suit best??

2) Also, I should be able to perform lookups based on playerId field in the
container,playerId would be an auto generated field for every object created
(irrespective of Derived Class I or Derived class II), please advice on
which container to choose in boost.

BTW I had a look at the multi-index container, in which case I would be
replicating data from the objects that I create, I am rather looking to see
if I can avoid copying data rather than do lookups based on the object
addresses in the container.

Thanks in advance for any suggestions / advice on this.

Regards
Ramesh



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net