Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2541


Ignore:
Timestamp:
Dec 28, 2008, 7:45:36 PM (15 years ago)
Author:
rgrieder
Message:

Added OrxEnum which is a template class that helps to create enumerations with unlimited entries since they are ints.
The only usage so far is for the ConfigFileType since we have about three predefined ones, but the KeyBinder would like to get new enum entries at run time.

Location:
code/branches/presentation
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/core/ConfigFileManager.h

    r2103 r2541  
    3838
    3939#include "util/Math.h"
     40#include "util/OrxEnum.h"
    4041
    4142namespace orxonox
    4243{
    43     // Use unsigned int as config file type to have an arbitrary number of files
    44     class ConfigFileType
    45     {
    46     public:
    47         ConfigFileType() { }
    48         ConfigFileType(unsigned int type)              { type_ = type; }
    49         ConfigFileType(const ConfigFileType& instance) { type_ = instance.type_; }
    50 
    51         operator unsigned int() { return type_; }
    52         ConfigFileType& operator =(unsigned int type) { type_ = type; return *this; }
    53         bool operator <(const ConfigFileType& right) const   { return (type_ < right.type_); }
    54 
    55         /* *** Put the different config file types here *** */
    56         static const unsigned int NoType              = 0;
    57         static const unsigned int Settings            = 1;
    58         static const unsigned int JoyStickCalibration = 2;
    59 
    60         static const unsigned int numberOfReservedTypes = 1024;
    61 
    62     private:
    63         unsigned int type_;
     44    // Use int as config file type to have an arbitrary number of files
     45    struct ConfigFileType : OrxEnum<ConfigFileType>
     46    {
     47        OrxEnumConstructors(ConfigFileType);
     48
     49        static const int NoType              = 0;
     50        static const int Settings            = 1;
     51        static const int JoyStickCalibration = 2;
     52
     53        static const int numberOfReservedTypes = 1024;
    6454    };
    6555
  • code/branches/presentation/visual_studio/vc8/util.vcproj

    r2171 r2541  
    173173                        </File>
    174174                        <File
     175                                RelativePath="..\..\src\util\OrxEnum.cc"
     176                                >
     177                        </File>
     178                        <File
    175179                                RelativePath="..\..\src\util\OutputBuffer.cc"
    176180                                >
     
    247251                        </File>
    248252                        <File
     253                                RelativePath="..\..\src\util\OrxEnum.h"
     254                                >
     255                        </File>
     256                        <File
    249257                                RelativePath="..\..\src\util\OrxonoxPlatform.h"
    250258                                >
Note: See TracChangeset for help on using the changeset viewer.