![]() |
MAK RTIspy API Documentation for HLA 1516
|
00001 /*********************************************************************** 00002 IEEE 1516.1 High Level Architecture Interface Specification C++ API 00003 File: RTI/Handle.h 00004 ***********************************************************************/ 00005 00006 #ifndef RTI_Handle_h 00007 #define RTI_Handle_h 00008 00009 #include <RTI/SpecificConfig.h> 00010 #include <RTI/Exception.h> 00011 #include <RTI/VariableLengthData.h> 00012 #include <string> 00013 00014 // The following macro is used to define each of the Handle classes 00015 // that are used by the RTI's API, e.g. AttributeHandle, ParameterHandle, etc. 00016 // Each kind of handle contains the same set of operators and functions, but 00017 // each is a separate class for type safety. The encode method can be used to 00018 // generate an encoded value for a handle, that can be sent to other federates 00019 // as an attribute or parameter. (Use RTIambassador functions to reconstruct a 00020 // handle from an encoded value). RTI implementations contain definitions 00021 // for each kind of the HandleKindImplementation classes (e.g. 00022 // AttributeHandleImplementation), but these classes are not needed by 00023 // federate code. 00024 00025 #define DEFINE_HANDLE_CLASS(HandleKind) \ 00026 \ 00027 /* Forward declaration for the RTI-internal class */ \ 00028 /* used to implement a specific kind of handle */ \ 00029 class HandleKind##Implementation; \ 00030 \ 00031 /* Each handle class generated by this macro provides the */ \ 00032 /* following interface */ \ 00033 class RTI_EXPORT HandleKind \ 00034 { \ 00035 public: \ 00036 \ 00037 /* Constructs an invalid handle */ \ 00038 HandleKind(); \ 00039 \ 00040 ~HandleKind() \ 00041 throw(); \ 00042 \ 00043 HandleKind(HandleKind const & rhs); \ 00044 \ 00045 HandleKind & \ 00046 operator=(HandleKind const & rhs); \ 00047 \ 00048 /* Indicates whether this handle is valid */ \ 00049 bool isValid() const; \ 00050 \ 00051 /* All invalid handles are equivalent */ \ 00052 bool operator==(HandleKind const & rhs) const; \ 00053 bool operator!=(HandleKind const & rhs) const; \ 00054 bool operator< (HandleKind const & rhs) const; \ 00055 \ 00056 /* Generate an encoded value that can be used to send */ \ 00057 /* handles to other federates in updates or interactions. */ \ 00058 VariableLengthData encode() const; \ 00059 \ 00060 /* Alternate encode for directly filling a buffer */ \ 00061 unsigned long encodedLength() const; \ 00062 unsigned long encode( \ 00063 void* buffer, unsigned long bufferSize) const \ 00064 throw (CouldNotEncode); \ 00065 \ 00066 std::wstring toString() const; \ 00067 \ 00068 protected: \ 00069 \ 00070 /* Friend declaration for an RTI-internal class that */ \ 00071 /* can access the implementation of a handle. */ \ 00072 friend class HandleKind##Friend; \ 00073 \ 00074 const HandleKind##Implementation* getImplementation() const; \ 00075 \ 00076 HandleKind##Implementation* getImplementation(); \ 00077 \ 00078 explicit \ 00079 HandleKind(HandleKind##Implementation* impl); \ 00080 \ 00081 explicit \ 00082 HandleKind(VariableLengthData const & encodedValue); \ 00083 \ 00084 HandleKind##Implementation* _impl; \ 00085 \ 00086 }; \ 00087 \ 00088 /* Output operator for Handles */ \ 00089 std::wostream RTI_EXPORT & \ 00090 operator << (std::wostream &, HandleKind const &); 00091 00092 00093 namespace rti1516 00094 { 00095 00096 // All of the RTI API's Handle classes are defined 00097 // by invoking the macro above. 00098 DEFINE_HANDLE_CLASS(FederateHandle) 00099 DEFINE_HANDLE_CLASS(ObjectClassHandle) 00100 DEFINE_HANDLE_CLASS(InteractionClassHandle) 00101 DEFINE_HANDLE_CLASS(ObjectInstanceHandle) 00102 DEFINE_HANDLE_CLASS(AttributeHandle) 00103 DEFINE_HANDLE_CLASS(ParameterHandle) 00104 DEFINE_HANDLE_CLASS(DimensionHandle) 00105 DEFINE_HANDLE_CLASS(MessageRetractionHandle) 00106 DEFINE_HANDLE_CLASS(RegionHandle) 00107 00108 } 00109 00110 #endif // RTI_Handle_h 00111