MAK RTIspy API Documentation for HLA Evolved
ulongHandleImpl.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 ** Copyright (c) 2003 MaK Technologies, Inc.
00003 ** All rights reserved.
00004 *********************************************************************/
00005 /*********************************************************************
00006 ** $RCSfile: ulongHandleImpl.h,v $ $Revision: 1.7 $ $State: Exp $
00007 *********************************************************************/
00008 
00011 
00012 #ifndef uloneHandleImplementation_H_
00013 #define uloneHandleImplementation_H_
00014 
00015 #include "rtiMsConfig.h"
00016 #include <RTI/VariableLengthData.h>
00017 #include <string>
00018 #include <sstream>
00019 #include "internalTypes.h"
00020 
00021 class DT_DLL_LRC ULongHandleImplementation
00022 {
00023 public:
00024 
00026    ULongHandleImplementation();
00027    ULongHandleImplementation(unsigned long handleValue);
00028    ULongHandleImplementation(ULongHandleImplementation const & rhs);
00029 
00031    ULongHandleImplementation & operator=(ULongHandleImplementation const & rhs);
00032 
00034    bool operator==(ULongHandleImplementation const & rhs) const;
00035    bool operator!=(ULongHandleImplementation const & rhs) const;
00036    bool operator< (ULongHandleImplementation const & rhs) const;
00037 
00040    rti1516::VariableLengthData encode() const;
00042    unsigned long encode(void* buffer, unsigned long bufferSize) const;
00043    unsigned long encodedLength() const;
00044 
00046    void decode(
00047       rti1516::VariableLengthData const & encodedHandle);
00048 
00050    void decode(void* buffer, unsigned long bufferSize);
00051 
00053    std::wstring toString() const;
00054 
00056    void setValue(long val);
00057    long value() const;
00058 
00059 protected:
00060    unsigned long myValue;
00061 };
00062 
00063 inline ULongHandleImplementation::ULongHandleImplementation() : myValue(0)
00064 {
00065 }
00066 inline ULongHandleImplementation::ULongHandleImplementation(
00067    unsigned long handleValue) : myValue(handleValue)
00068 {
00069 }
00070 inline ULongHandleImplementation::ULongHandleImplementation(
00071    ULongHandleImplementation const & rhs) : myValue(rhs.myValue)
00072 {
00073 }
00074 
00075 inline ULongHandleImplementation & ULongHandleImplementation::operator=(
00076    ULongHandleImplementation const & rhs)
00077 {
00078    if (this == &rhs)
00079       return *this;
00080    myValue = rhs.myValue;
00081    return *this;
00082 }
00083 
00084 inline bool ULongHandleImplementation::operator==(
00085    ULongHandleImplementation const & rhs) const
00086 {
00087    return myValue == rhs.myValue;
00088 }
00089 inline bool ULongHandleImplementation::operator!=(
00090    ULongHandleImplementation const & rhs) const
00091 {
00092    return myValue != rhs.myValue;
00093 }
00094 inline bool ULongHandleImplementation::operator< (
00095    ULongHandleImplementation const & rhs) const
00096 {
00097    return myValue < rhs.myValue;
00098 }
00099 
00100 inline rti1516::VariableLengthData ULongHandleImplementation::encode() const
00101 {
00102    DtNetU32 netValue = myValue;
00103    return rti1516::VariableLengthData(&netValue, sizeof(netValue));
00104 }
00105 inline unsigned long ULongHandleImplementation::encode(void* buffer,
00106    unsigned long bufferSize) const
00107 {
00108    DtNetU32 netValue = myValue;
00109    if (bufferSize < sizeof(netValue))
00110       return 0;
00111    memcpy(buffer, &netValue, sizeof(netValue));
00112    return sizeof(netValue);
00113 }
00114 inline unsigned long ULongHandleImplementation::encodedLength() const
00115 {
00116    return sizeof(DtNetU32);
00117 }
00118 
00119 inline std::wstring ULongHandleImplementation::toString() const
00120 {
00121    std::wstringstream ss;
00122    ss << myValue;
00123    return ss.str();
00124 }
00125 
00126 inline void ULongHandleImplementation::setValue(long val)
00127 {
00128    myValue = myValue;
00129 }
00130 inline long ULongHandleImplementation::value() const
00131 {
00132    return myValue;
00133 }
00134 inline void ULongHandleImplementation::decode(
00135    rti1516::VariableLengthData const & encodedHandle)
00136 {
00137    myValue = *((DtNetU32*)encodedHandle.data());
00138 }
00139 
00140 inline void ULongHandleImplementation::decode(void* buffer,
00141    unsigned long bufferSize)
00142 {
00143    myValue = *((DtNetU32*)buffer);
00144 }
00145 
00146 #endif //! uloneHandleImplementation_H_

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)