MAK RTIspy API Documentation for HLA Evolved
Handle.h
Go to the documentation of this file.
00001 /***********************************************************************
00002    The IEEE hereby grants a general, royalty-free license to copy, distribute,
00003    display and make derivative works from this material, for all purposes,
00004    provided that any use of the material contains the following
00005    attribution: "Reprinted with permission from IEEE 1516.1(TM)-2010".
00006    Should you require additional information, contact the Manager, Standards
00007    Intellectual Property, IEEE Standards Association (stds-ipr@ieee.org).
00008 ***********************************************************************/
00009 /***********************************************************************
00010    IEEE 1516.1 High Level Architecture Interface Specification C++ API
00011    File: RTI/Handle.h
00012 ***********************************************************************/
00013 
00014 #ifndef RTI_Handle_h
00015 #define RTI_Handle_h
00016 
00017 #include <RTI/SpecificConfig.h>
00018 #include <RTI/Exception.h>
00019 #include <RTI/VariableLengthData.h>
00020 #include <string>
00021 
00022 // The following macro is used to define each of the Handle classes
00023 // that are used by the RTI's API, e.g. AttributeHandle, ParameterHandle, etc.
00024 // Each kind of handle contains the same set of operators and functions, but
00025 // each is a separate class for type safety.  The encode method can be used to
00026 // generate an encoded value for a handle, that can be sent to other federates
00027 // as an attribute or parameter.  (Use RTIambassador functions to reconstruct a
00028 // handle from an encoded value).  RTI implementations contain definitions
00029 // for each kind of the HandleKindImplementation classes (e.g.
00030 // AttributeHandleImplementation), but these classes are not needed by
00031 // federate code.
00032 
00033 #define DEFINE_HANDLE_CLASS(HandleKind)                           \
00034                                                                   \
00035 /* Forward declaration for the RTI-internal class            */   \
00036 /* used to implement a specific kind of handle               */   \
00037 class HandleKind##Implementation;                                 \
00038                                                                   \
00039 /* Each handle class generated by this macro provides the    */   \
00040 /* following interface                                       */   \
00041 class RTI_EXPORT HandleKind                                       \
00042 {                                                                 \
00043    public:                                                        \
00044                                                                   \
00045    /* Constructs an invalid handle                           */   \
00046    HandleKind ();                                                 \
00047                                                                   \
00048    ~HandleKind ()                                                 \
00049       throw();                                                    \
00050                                                                   \
00051    HandleKind (                                                   \
00052       HandleKind const & rhs);                                    \
00053                                                                   \
00054    HandleKind & operator= (                                       \
00055       HandleKind const & rhs);                                    \
00056                                                                   \
00057    /* Indicates whether this handle is valid                 */   \
00058    bool isValid () const;                                         \
00059                                                                   \
00060    /* All invalid handles are equivalent                     */   \
00061    bool operator== (                                              \
00062       HandleKind const & rhs) const;                              \
00063                                                                   \
00064    bool operator!= (                                              \
00065       HandleKind const & rhs) const;                              \
00066                                                                   \
00067    bool operator< (                                               \
00068       HandleKind const & rhs) const;                              \
00069                                                                   \
00070    /* Generate a hash value for use in storing handles in a  */   \
00071    /* in a hash table.                                       */   \
00072    /* Note: The hash value may not be unique across two      */   \
00073    /* separate handle values but it will be equal given two  */   \
00074    /* separate instances of the same handle value.           */   \
00075    /* H1 == H2 implies H1.hash() == H2.hash()                */   \
00076    /* H1 != H2 does not imply H1.hash() != H2.hash()         */   \
00077    long hash () const;                                            \
00078                                                                   \
00079    /* Generate an encoded value that can be used to send     */   \
00080    /* handles to other federates in updates or interactions. */   \
00081    VariableLengthData encode () const;                            \
00082                                                                   \
00083    /* Encode into an existing VariableLengthData             */   \
00084    void encode (VariableLengthData& buffer) const;                \
00085                                                                   \
00086    /* Alternate encode for directly filling a buffer         */   \
00087    size_t encode (                                                \
00088       void* buffer,                                               \
00089       size_t bufferSize) const                                    \
00090       throw (CouldNotEncode);                                     \
00091                                                                   \
00092    size_t encodedLength () const;                                 \
00093                                                                   \
00094    std::wstring toString () const;                                \
00095                                                                   \
00096    protected:                                                     \
00097                                                                   \
00098    /* Friend declaration for an RTI-internal class that      */   \
00099    /* can access the implementation of a handle.             */   \
00100    friend class HandleKind##Friend;                               \
00101                                                                   \
00102    const HandleKind##Implementation* getImplementation () const;  \
00103                                                                   \
00104    HandleKind##Implementation* getImplementation ();              \
00105                                                                   \
00106    explicit HandleKind (                                          \
00107       HandleKind##Implementation* impl);                          \
00108                                                                   \
00109    explicit HandleKind (                                          \
00110       VariableLengthData const & encodedValue);                   \
00111                                                                   \
00112    HandleKind##Implementation* _impl;                             \
00113                                                                   \
00114 };                                                                \
00115                                                                   \
00116 /* Output operator for Handles                               */   \
00117 std::wostream RTI_EXPORT &                                        \
00118 operator<< (                                                      \
00119    std::wostream &,                                               \
00120    HandleKind const &);
00121 
00122 
00123 namespace rti1516e
00124 {
00125 
00126 // All of the RTI API's Handle classes are defined
00127 // by invoking the macro above.
00128 DEFINE_HANDLE_CLASS(FederateHandle)
00129 DEFINE_HANDLE_CLASS(ObjectClassHandle)
00130 DEFINE_HANDLE_CLASS(InteractionClassHandle)
00131 DEFINE_HANDLE_CLASS(ObjectInstanceHandle)
00132 DEFINE_HANDLE_CLASS(AttributeHandle)
00133 DEFINE_HANDLE_CLASS(ParameterHandle)
00134 DEFINE_HANDLE_CLASS(DimensionHandle)
00135 DEFINE_HANDLE_CLASS(MessageRetractionHandle)
00136 DEFINE_HANDLE_CLASS(RegionHandle)
00137 
00138 }
00139 
00140 #endif // RTI_Handle_h
00141 

Document ID: Generated on Thu Jun 14 14:15:04 EDT 2012 from SVN revision 116116
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)