Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

working on player limits

File size: 2.5 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#include "proxy/proxy_settings.h"
12
13
14class NetworkStream;
15class Synchronizeable;
16
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 maximum number of players for this server */
40    inline int getMaxPlayer() { return ProxySettings::getInstance()->getMaxPlayer(); }
41
42    /** @returns the hostID of the node */
43    inline int getHostID() { return this->hostID; }
44    /** sets the hostID of this node @param hostID of the node */
45    inline void setHostID(int hostID) { this->hostID = hostID; }
46
47    /** @returns the default synchronize stream */
48    inline NetworkStream* getDefaultSyncStream() { return this->defaultSyncStream; }
49    /** sets the default sync stream @param defaultSyncStream the default sync stream */
50    inline void setDefaultSyncStream(NetworkStream* defaultSyncStream) { this->defaultSyncStream = defaultSyncStream; }
51
52
53  private:
54    SharedNetworkData();
55
56
57  private:
58    int                             newUniqueID;             //!< next uniqueID
59    int                             nodeType;                //!< saves the node type here
60
61    int                             hostID;                  //!< The Host-ID of the Manager
62    NetworkStream*                  defaultSyncStream;       //!< default synchronize NetworkStream
63
64    static SharedNetworkData*       singletonRef;            //!< Pointer to the only instance of this Class
65
66};
67
68
69
70#endif /* _SHARED_NETWORK_DATA */
Note: See TracBrowser for help on using the repository browser.