Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/network/shared_network_data.h @ 10209

Last change on this file since 10209 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 3.6 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/network_settings.h"
12
13//!< maximal connectinons for the server
14#define NET_MAX_CONNECTIONS 2
15
16
17class Synchronizeable;
18class NetworkMonitor;
19
20
21/* and here is the class itsself*/
22class SharedNetworkData : public BaseObject
23{
24  ObjectListDeclaration(SharedNetworkData);
25  public:
26    inline static SharedNetworkData* getInstance() { if (!SharedNetworkData::singletonRef) SharedNetworkData::singletonRef = new SharedNetworkData();
27      return SharedNetworkData::singletonRef; }
28    virtual ~SharedNetworkData();
29
30    /** @returns the next uniqueID free for an object */
31    inline int getNewUniqueID() { return ( isMasterServer())?this->newUniqueID++:-1; }
32    /** sets the @param newUniqueID: the new offset for the next unique id */
33    inline void setNewUniqueID(int newUniqueID) { this->newUniqueID = newUniqueID; }
34
35    /** sets the game server flag @param bGameServer true if it is a game server */
36    inline void setNodeType(int nodeType) { this->nodeType = nodeType; }
37    /** @returns true is this node is a master server */
38    inline bool isMasterServer() { return this->nodeType == NET_MASTER_SERVER; }
39    /** @returns true is this node is a proxy server */
40    inline bool isProxyServerActive() { return this->nodeType == NET_PROXY_SERVER_ACTIVE; }
41    /** @returns true is this node is a client*/
42    inline bool isClient() { return this->nodeType == NET_CLIENT; }
43
44    /** @return true if this user is connected to the local host */
45    bool isUserLocal( int userID);
46    /** @returns true if this user is a master server */
47    bool isUserMasterServer( int userID );
48    /** @returns true if this user is a proxy server */
49    bool isUserProxyServerActive( int userID );
50    /** @returns true if this user is a client */
51    bool isUserClient( int userID );
52
53
54    /** @returns the maximum number of players for this server */
55    inline int getMaxPlayer() { return NetworkSettings::getInstance()->getMaxPlayer(); }
56
57    /** @returns the hostID of the node */
58    inline int getHostID() { return this->hostID; }
59    /** sets the hostID of this node @param hostID of the node */
60    inline void setHostID(int hostID) { this->hostID = hostID; }
61
62    /** @returns the default synchronize stream */
63    inline NetworkStream* getDefaultSyncStream() { return this->defaultSyncStream; }
64    /** sets the default sync stream @param defaultSyncStream the default sync stream */
65    inline void setDefaultSyncStream(NetworkStream* defaultSyncStream) { this->defaultSyncStream = defaultSyncStream; }
66
67    /** @returns the network monitor reference */
68    inline NetworkMonitor* getNetworkMonitor() { return this->networkMonitor; }
69    /** @param networkMonitor sets the NetworkMonitor reference */
70    inline void setNetworkMonitor( NetworkMonitor* networkMonitor) { this->networkMonitor = networkMonitor; }
71
72
73  private:
74    SharedNetworkData();
75
76
77  private:
78    int                             newUniqueID;             //!< next uniqueID
79    int                             nodeType;                //!< saves the node type here
80
81    int                             hostID;                  //!< The Host-ID of the Manager
82    NetworkStream*                  defaultSyncStream;       //!< default synchronize NetworkStream
83    NetworkMonitor*                 networkMonitor;          //!< reference to the NetworkMonitor
84
85    static SharedNetworkData*       singletonRef;            //!< Pointer to the only instance of this Class
86
87};
88
89
90
91#endif /* _SHARED_NETWORK_DATA */
Note: See TracBrowser for help on using the repository browser.