/* $Id: itemset.hpp,v 1.6 2005/12/10 15:59:12 chfreund Exp $ */ #ifndef _ITEMSET_HPP_ #define _ITEMSET_HPP_ /**********************************************************/ #include #include "settings.hpp" #include "pvector_t.hpp" /**********************************************************/ //! base interface for items /*! This class is the base interface class for items, that should * be able to be loaded from a list in a configuration file. */ class Item { public: //! constructor Item() {}; //! destructor virtual ~Item() {}; virtual bool readFromSettings( SettingDataBase &settings, Sint32 &pos ) = 0; //! static bool checkSettings( SettingDataBase &settings ) { return true; } //! returns static const SettingDef* getSettingDef() { ASSERT( false, "Item::getSettingDef should not " "be called\n" ); return 0x0; } }; /**********************************************************/ //! T must be derived from class Item template class ItemSet : protected PointerVector { public: ItemSet(); virtual ~ItemSet(); //! \name access methods //@{ //! returns number of items in the set Sint32 getNumItems() const { return static_cast(PointerVector::getSize()); } //! returns item at passed index \c [i] T& getItem( const Sint32 i ) { return *(T*)(PointerVector::operator [] (i)); } //! returns item at passed index \c [i] const T& getItem( const Sint32 i ) const { return *(const T*)(PointerVector::operator [] (i)); } //! append an item bool append( const T* item ) { return PointerVector::append( item ); } //@} //! loads the item set from section \c section in file \c filename virtual bool load( const char* const filename, const char* const section ); void reset(); protected: }; /**********************************************************/ #endif // _ITEMSET_HPP_