MAK RTIspy API Documentation for HLA Evolved
ulongHandleImpl.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 2003 MaK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: ulongHandleImpl.h,v $ $Revision: 1.7 $ $State: Exp $
7 *********************************************************************/
8 
11 
12 #ifndef uloneHandleImplementation_H_
13 #define uloneHandleImplementation_H_
14 
15 #include "rtiMsConfig.h"
16 #include <RTI/VariableLengthData.h>
17 #include <string>
18 #include <sstream>
19 #include "internalTypes.h"
20 
22 {
23 public:
24 
27  ULongHandleImplementation(unsigned long handleValue);
29 
32 
34  bool operator==(ULongHandleImplementation const & rhs) const;
35  bool operator!=(ULongHandleImplementation const & rhs) const;
36  bool operator< (ULongHandleImplementation const & rhs) const;
37 
40  rti1516::VariableLengthData encode() const;
42  unsigned long encode(void* buffer, unsigned long bufferSize) const;
43  unsigned long encodedLength() const;
44 
46  void decode(
47  rti1516::VariableLengthData const & encodedHandle);
48 
50  void decode(void* buffer, unsigned long bufferSize);
51 
53  std::wstring toString() const;
54 
56  void setValue(long val);
57  long value() const;
58 
59 protected:
60  unsigned long myValue;
61 };
62 
64 {
65 }
67  unsigned long handleValue) : myValue(handleValue)
68 {
69 }
71  ULongHandleImplementation const & rhs) : myValue(rhs.myValue)
72 {
73 }
74 
76  ULongHandleImplementation const & rhs)
77 {
78  if (this == &rhs)
79  return *this;
80  myValue = rhs.myValue;
81  return *this;
82 }
83 
85  ULongHandleImplementation const & rhs) const
86 {
87  return myValue == rhs.myValue;
88 }
90  ULongHandleImplementation const & rhs) const
91 {
92  return myValue != rhs.myValue;
93 }
95  ULongHandleImplementation const & rhs) const
96 {
97  return myValue < rhs.myValue;
98 }
99 
101 {
102  DtNetU32 netValue = myValue;
103  return rti1516::VariableLengthData(&netValue, sizeof(netValue));
104 }
105 inline unsigned long ULongHandleImplementation::encode(void* buffer,
106  unsigned long bufferSize) const
107 {
108  DtNetU32 netValue = myValue;
109  if (bufferSize < sizeof(netValue))
110  return 0;
111  memcpy(buffer, &netValue, sizeof(netValue));
112  return sizeof(netValue);
113 }
114 inline unsigned long ULongHandleImplementation::encodedLength() const
115 {
116  return sizeof(DtNetU32);
117 }
118 
119 inline std::wstring ULongHandleImplementation::toString() const
120 {
121  std::wstringstream ss;
122  ss << myValue;
123  return ss.str();
124 }
125 
127 {
128  myValue = myValue;
129 }
131 {
132  return myValue;
133 }
135  rti1516::VariableLengthData const & encodedHandle)
136 {
137  myValue = *((DtNetU32*)encodedHandle.data());
138 }
139 
140 inline void ULongHandleImplementation::decode(void* buffer,
141  unsigned long bufferSize)
142 {
143  myValue = *((DtNetU32*)buffer);
144 }
145 
146 #endif

Document ID: Generated on Tue May 7 16:26:47 EDT 2013 from SVN revision 126903
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)