Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/new_class_id/src/lib/network/shared_network_data.h @ 9690

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

some network-stuff

File size: 3.6 KB
RevLine 
[6678]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"
[9406]10#include "netdefs.h"
11#include "proxy/network_settings.h"
[6678]12
[9406]13//!< maximal connectinons for the server
14#define NET_MAX_CONNECTIONS 2
[6678]15
[9494]16
[6678]17class Synchronizeable;
[9656]18class NetworkMonitor;
[6678]19
[9406]20
[6678]21/* and here is the class itsself*/
22class SharedNetworkData : public BaseObject
23{
[9690]24  NewObjectListDeclaration(SharedNetworkData);
[6678]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 */
[9494]31    inline int getNewUniqueID() { return ( isMasterServer())?this->newUniqueID++:-1; }
[9406]32    /** sets the @param newUniqueID: the new offset for the next unique id */
33    inline void setNewUniqueID(int newUniqueID) { this->newUniqueID = newUniqueID; }
[6678]34
[9494]35    /** sets the game server flag @param bGameServer true if it is a game server */
36    inline void setNodeType(int nodeType) { this->nodeType = nodeType; }
[9406]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 */
[9494]40    inline bool isProxyServerActive() { return this->nodeType == NET_PROXY_SERVER_ACTIVE; }
[9406]41    /** @returns true is this node is a client*/
42    inline bool isClient() { return this->nodeType == NET_CLIENT; }
[6678]43
[9494]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
[9406]54    /** @returns the maximum number of players for this server */
55    inline int getMaxPlayer() { return NetworkSettings::getInstance()->getMaxPlayer(); }
56
[6678]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
[9656]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; }
[6678]71
[9656]72
[6678]73  private:
74    SharedNetworkData();
75
76
77  private:
78    int                             newUniqueID;             //!< next uniqueID
[9406]79    int                             nodeType;                //!< saves the node type here
80
[6678]81    int                             hostID;                  //!< The Host-ID of the Manager
82    NetworkStream*                  defaultSyncStream;       //!< default synchronize NetworkStream
[9656]83    NetworkMonitor*                 networkMonitor;          //!< reference to the NetworkMonitor
[6678]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.