MAK RTIspy API Documentation for HLA 4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Handle.h
Go to the documentation of this file.
1 #pragma once
2 /***********************************************************************
3  The IEEE hereby grants a general, royalty-free license to copy, distribute,
4  display and make derivative works from this material, for all purposes,
5  provided that any use of the material contains the following
6  attribution: "Reprinted with permission from IEEE 1516.1(TM)-2025".
7  Should you require additional information, contact the Manager, Standards
8  Intellectual Property, IEEE Standards Association (stds-ipr@ieee.org).
9 ***********************************************************************/
10 
11 #include <RTI/SpecificConfig.h>
12 #include <RTI/Exception.h>
13 #include <RTI/VariableLengthData.h>
14 #include <string>
15 
16 // The following macro is used to define each of the Handle classes
17 // that are used by the RTI's API, e.g. AttributeHandle, ParameterHandle, etc.
18 // Each kind of handle contains the same set of operators and functions, but
19 // each is a separate class for type safety. The encode method can be used to
20 // generate an encoded value for a handle, that can be sent to other federates
21 // as an attribute or parameter. (Use RTIambassador functions to reconstruct a
22 // handle from an encoded value). RTI implementations contain definitions
23 // for each kind of the HandleKindImplementation classes (e.g.
24 // AttributeHandleImplementation), but these classes are not needed by
25 // federate code.
26 
27 #define DEFINE_HANDLE_CLASS(HandleKind) \
28  \
29 /* Forward declaration for the RTI-internal class */ \
30 /* used to implement a specific kind of handle */ \
31 class HandleKind##Implementation; \
32  \
33 /* Each handle class generated by this macro provides the */ \
34 /* following interface */ \
35 class RTI_EXPORT HandleKind \
36 { \
37  public: \
38  \
39  /* Constructs an invalid handle */ \
40  HandleKind (); \
41  \
42  ~HandleKind () \
43  noexcept; \
44  \
45  HandleKind ( \
46  HandleKind const & rhs); \
47  \
48  HandleKind & operator= ( \
49  HandleKind const & rhs); \
50  \
51  /* Indicates whether this handle is valid */ \
52  bool isValid () const; \
53  \
54  /* All invalid handles are equivalent */ \
55  bool operator== ( \
56  HandleKind const & rhs) const; \
57  \
58  bool operator!= ( \
59  HandleKind const & rhs) const; \
60  \
61  bool operator< ( \
62  HandleKind const & rhs) const; \
63  \
64  /* Generate a hash value for use in storing handles in a */ \
65  /* in a hash table. */ \
66  /* Note: The hash value may not be unique across two */ \
67  /* separate handle values but it will be equal given two */ \
68  /* separate instances of the same handle value. */ \
69  /* H1 == H2 implies H1.hash() == H2.hash() */ \
70  /* H1 != H2 does not imply H1.hash() != H2.hash() */ \
71  long hash () const; \
72  \
73  /* Generate an encoded value that can be used to send */ \
74  /* handles to other federates in updates or interactions. */ \
75  VariableLengthData encode () const; \
76  \
77  /* Encode into an existing VariableLengthData */ \
78  void encode (VariableLengthData& buffer) const; \
79  \
80  \
81  size_t encode ( \
82  void* buffer, \
83  size_t bufferSize) const; \
84  \
85  size_t encodedLength () const; \
86  \
87  std::wstring toString () const; \
88  \
89  protected: \
90  \
91  /* Friend declaration for an RTI-internal class that */ \
92  /* can access the implementation of a handle. */ \
93  friend class HandleKind##Friend; \
94  \
95  const HandleKind##Implementation* getImplementation () const; \
96  \
97  HandleKind##Implementation* getImplementation (); \
98  \
99  explicit HandleKind ( \
100  HandleKind##Implementation* impl); \
101  \
102  explicit HandleKind ( \
103  VariableLengthData const & encodedValue); \
104  \
105  HandleKind##Implementation* _impl; \
106  \
107 }; \
108  \
109 /* Output operator for Handles */ \
110 std::wostream RTI_EXPORT & \
111 operator<< ( \
112  std::wostream &, \
113  HandleKind const &);
114 
115 
116 namespace rti1516_2025
117 {
118 
119 // All of the RTI API's Handle classes are defined
120 // by invoking the macro above.
121 DEFINE_HANDLE_CLASS(FederateHandle)
122 DEFINE_HANDLE_CLASS(ObjectClassHandle)
123 DEFINE_HANDLE_CLASS(InteractionClassHandle)
124 DEFINE_HANDLE_CLASS(ObjectInstanceHandle)
125 DEFINE_HANDLE_CLASS(AttributeHandle)
126 DEFINE_HANDLE_CLASS(ParameterHandle)
127 DEFINE_HANDLE_CLASS(DimensionHandle)
128 DEFINE_HANDLE_CLASS(MessageRetractionHandle)
129 DEFINE_HANDLE_CLASS(RegionHandle)
130 DEFINE_HANDLE_CLASS(TransportationTypeHandle)
131 
132 }
133 
134 
135 
his file contains a class to hold an arbitrary array of bytes for encoded values, attribute values...
This file contains definitions that are used to isolate platform-specific elements of the API...
#define DEFINE_HANDLE_CLASS(HandleKind)
Definition: Handle.h:27

Document ID: Generated on Wed Jul 8 16:20:32 EDT 2026 from SVN revision 291616
Copyright © 2005-2025 MAK Technologies Inc. All Rights Reserved (www.mak.com)