Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/proxy/src/lib/network/shared_network_data.h @ 9303

Last change on this file since 9303 was 9303, checked in by patrick, 18 years ago

framework integration

File size: 2.4 KB
Line 
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#include "netdefs.h"
11
12
13class NetworkStream;
14class Synchronizeable;
15template<typename>
16    class tList;
17
18/* and here is the class itsself*/
19class SharedNetworkData : public BaseObject
20{
21
22  public:
23    inline static SharedNetworkData* getInstance() { if (!SharedNetworkData::singletonRef) SharedNetworkData::singletonRef = new SharedNetworkData();
24      return SharedNetworkData::singletonRef; }
25    virtual ~SharedNetworkData();
26
27    /** @returns the next uniqueID free for an object */
28    inline int getNewUniqueID() { return ( this->nodeType != NET_CLIENT)?this->newUniqueID++:-1; }
29
30    /** @returns true is this node is a master server */
31    inline bool isMasterServer() { return this->nodeType == NET_MASTER_SERVER; }
32    /** @returns true is this node is a proxy server */
33    inline bool isProxyServer() { return this->nodeType == NET_PROXY_SERVER_ACTIVE; }
34    /** @returns true is this node is a client*/
35    inline bool isClient() { return this->nodeType == NET_CLIENT; }
36    /** sets the game server flag @param bGameServer true if it is a game server */
37    inline void setNodeType(int nodeType) { this->nodeType = nodeType; }
38
39    /** @returns the hostID of the node */
40    inline int getHostID() { return this->hostID; }
41    /** sets the hostID of this node @param hostID of the node */
42    inline void setHostID(int hostID) { this->hostID = hostID; }
43
44    /** @returns the default synchronize stream */
45    inline NetworkStream* getDefaultSyncStream() { return this->defaultSyncStream; }
46    /** sets the default sync stream @param defaultSyncStream the default sync stream */
47    inline void setDefaultSyncStream(NetworkStream* defaultSyncStream) { this->defaultSyncStream = defaultSyncStream; }
48
49
50  private:
51    SharedNetworkData();
52
53
54  private:
55    int                             newUniqueID;             //!< next uniqueID
56    int                             nodeType;                //!< saves the node type here
57
58    int                             hostID;                  //!< The Host-ID of the Manager
59    NetworkStream*                  defaultSyncStream;       //!< default synchronize NetworkStream
60
61    static SharedNetworkData*       singletonRef;            //!< Pointer to the only instance of this Class
62
63};
64
65
66
67#endif /* _SHARED_NETWORK_DATA */
Note: See TracBrowser for help on using the repository browser.