| 1 | /*! | 
|---|
| 2 |  * @file shared_network_data.h | 
|---|
| 3 |  *  some shared data from the NetworkManager | 
|---|
| 4 |  */ | 
|---|
| 5 |  | 
|---|
| 6 | #ifndef _SHARED_NETWORK_DATA | 
|---|
| 7 | #define _SHARED_NETWORK_DATA | 
|---|
| 8 |  | 
|---|
| 9 | #include "base_object.h" | 
|---|
| 10 |  | 
|---|
| 11 |  | 
|---|
| 12 | class NetworkStream; | 
|---|
| 13 | class Synchronizeable; | 
|---|
| 14 | template<typename> | 
|---|
| 15 |     class tList; | 
|---|
| 16 |  | 
|---|
| 17 | /* and here is the class itsself*/ | 
|---|
| 18 | class SharedNetworkData : public BaseObject | 
|---|
| 19 | { | 
|---|
| 20 |  | 
|---|
| 21 |   public: | 
|---|
| 22 |     inline static SharedNetworkData* getInstance() { if (!SharedNetworkData::singletonRef) SharedNetworkData::singletonRef = new SharedNetworkData(); | 
|---|
| 23 |       return SharedNetworkData::singletonRef; } | 
|---|
| 24 |     virtual ~SharedNetworkData(); | 
|---|
| 25 |  | 
|---|
| 26 |     /** @returns the next uniqueID free for an object */ | 
|---|
| 27 |     inline int getNewUniqueID() { return ( this->bGameServer)?this->newUniqueID++:-1; } | 
|---|
| 28 |  | 
|---|
| 29 |     /** @returns true is this node is a game server */ | 
|---|
| 30 |     inline bool isGameServer() { return this->bGameServer; } | 
|---|
| 31 |     /** sets the game server flag @param bGameServer true if it is a game server */ | 
|---|
| 32 |     inline void setGameServer(bool bGameServer) { this->bGameServer = bGameServer; } | 
|---|
| 33 |  | 
|---|
| 34 |     /** @returns the hostID of the node */ | 
|---|
| 35 |     inline int getHostID() { return this->hostID; } | 
|---|
| 36 |     /** sets the hostID of this node @param hostID of the node */ | 
|---|
| 37 |     inline void setHostID(int hostID) { this->hostID = hostID; } | 
|---|
| 38 |  | 
|---|
| 39 |     /** @returns the default synchronize stream */ | 
|---|
| 40 |     inline NetworkStream* getDefaultSyncStream() { return this->defaultSyncStream; } | 
|---|
| 41 |     /** sets the default sync stream @param defaultSyncStream the default sync stream */ | 
|---|
| 42 |     inline void setDefaultSyncStream(NetworkStream* defaultSyncStream) { this->defaultSyncStream = defaultSyncStream; } | 
|---|
| 43 |  | 
|---|
| 44 |  | 
|---|
| 45 |   private: | 
|---|
| 46 |     SharedNetworkData(); | 
|---|
| 47 |  | 
|---|
| 48 |  | 
|---|
| 49 |   private: | 
|---|
| 50 |     int                             newUniqueID;             //!< next uniqueID | 
|---|
| 51 |     bool                            bGameServer;             //!< true if it is a server | 
|---|
| 52 |     int                             hostID;                  //!< The Host-ID of the Manager | 
|---|
| 53 |     NetworkStream*                  defaultSyncStream;       //!< default synchronize NetworkStream | 
|---|
| 54 |  | 
|---|
| 55 |     static SharedNetworkData*       singletonRef;            //!< Pointer to the only instance of this Class | 
|---|
| 56 |  | 
|---|
| 57 | }; | 
|---|
| 58 |  | 
|---|
| 59 |  | 
|---|
| 60 |  | 
|---|
| 61 | #endif /* _SHARED_NETWORK_DATA */ | 
|---|