SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NetworkIDManager.h
Go to the documentation of this file.
1 /*
2 * Original work: Copyright (c) 2014, Oculus VR, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * RakNet License.txt file in the licenses directory of this source tree. An additional grant
7 * of patent rights can be found in the RakNet Patents.txt file in the same directory.
8 *
9 *
10 * Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
11 *
12 * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
13 * license found in the license.txt file in the root directory of this source tree.
14 */
15
18
19
20 #ifndef __NETWORK_ID_MANAGER_H
21 #define __NETWORK_ID_MANAGER_H
22
23 #include "types.h"
24 #include "Export.h"
25 #include "memoryoverride.h"
26 #include "NetworkIDObject.h"
27 #include "Rand.h"
28
29 namespace SLNet
30 {
31
34 #define NETWORK_ID_MANAGER_HASH_LENGTH 1024
35
40 class RAK_DLL_EXPORT NetworkIDManager
41 {
42 public:
43 // GetInstance() and DestroyInstance(instance*)
44 STATIC_FACTORY_DECLARATIONS(NetworkIDManager)
45
46 NetworkIDManager();
47 virtual ~NetworkIDManager(void);
48
52 template <class returnType>
53 returnType GET_OBJECT_FROM_ID(NetworkID x) {
54 NetworkIDObject *nio = GET_BASE_OBJECT_FROM_ID(x);
55 if (nio==0)
56 return 0;
57 if (nio->GetParent())
58 return (returnType) nio->GetParent();
59 return (returnType) nio;
60 }
61
62 // Stop tracking all NetworkID objects
63 void Clear(void);
64
66 NetworkIDObject *GET_BASE_OBJECT_FROM_ID(NetworkID x);
67
68 protected:
70 void TrackNetworkIDObject(NetworkIDObject *networkIdObject);
71 void StopTrackingNetworkIDObject(NetworkIDObject *networkIdObject);
72
73 friend class NetworkIDObject;
74
75 NetworkIDObject *networkIdHash[NETWORK_ID_MANAGER_HASH_LENGTH];
76 unsigned int NetworkIDToHashIndex(NetworkID networkId);
77 uint64_t startingOffset;
79 NetworkID GetNewNetworkID(void);
80
81 };
82
83 } // namespace SLNet
84
85 #endif