MAK RTIspy API Documentation for HLA 1516
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
Definition: ulongHandleImpl.h:21
std::wstring toString() const
Return a string representation of handle.
Definition: ulongHandleImpl.h:119
ULongHandleImplementation & operator=(ULongHandleImplementation const &rhs)
Assignment.
Definition: ulongHandleImpl.h:75
std::string toString(const std::wstring &inString)
Definition: objParams13.h:16
bool operator<(ULongHandleImplementation const &rhs) const
Definition: ulongHandleImpl.h:94
bool operator==(ULongHandleImplementation const &rhs) const
Relational operators.
Definition: ulongHandleImpl.h:84
rti1516::VariableLengthData encode() const
Generate an encoded value that can be used to send handles to other federates in updates or interacti...
Definition: ulongHandleImpl.h:100
ULongHandleImplementation()
Constructors.
Definition: ulongHandleImpl.h:63
void decode(rti1516::VariableLengthData const &encodedHandle)
Decode VariableLengthData into self.
Definition: ulongHandleImpl.h:134
his file contains a class to hold an arbitrary array of bytes for encoded values, attribute values...
Definition: VariableLengthData.h:22
#define DT_DLL_LRC
Definition: rtiMsConfig.h:126
long value() const
Definition: ulongHandleImpl.h:130
unsigned long myValue
Definition: ulongHandleImpl.h:60
The declaration of internal types.
bool operator!=(ULongHandleImplementation const &rhs) const
Definition: ulongHandleImpl.h:89
void const * data() const
void setValue(long val)
Set/Get implementation.
Definition: ulongHandleImpl.h:126
unsigned long encodedLength() const
Definition: ulongHandleImpl.h:114

Document ID: Generated on Mon Sep 7 15:40:32 EDT 2020 from SVN revision 217499
Copyright © 2005-2020 MAK Technologies Inc. All Rights Reserved (www.mak.com)