[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[certi-cvs] certi libRTI/ieee1516-2010/RTIvariableLengthDat...
From: |
CERTI CVS commits |
Subject: |
[certi-cvs] certi libRTI/ieee1516-2010/RTIvariableLengthDat... |
Date: |
Mon, 03 Mar 2014 16:43:30 +0000 |
CVSROOT: /sources/certi
Module name: certi
Changes by: Eric NOULARD <erk> 14/03/03 16:43:30
Added files:
libRTI/ieee1516-2010: RTIvariableLengthData.cpp
LogicalTimeDouble.h HandleImplementation.h
RTIHandleFactory.cpp Handle.cpp
Exception.cpp
RTIvariableLengthDataImplementation.h
RTI1516fedTime.cpp LogicalTimeDouble.cpp
RTIHandleFactory.h
HandleImplementation.cpp
include/ieee1516-2010/RTI: certiLogicalTimeInterval.h
certiRTI1516.h certiLogicalTime.h
certiLogicalTimeFactory.h
Log message:
Prepare IEEE-1516-2010 library build
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/libRTI/ieee1516-2010/RTIvariableLengthData.cpp?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libRTI/ieee1516-2010/LogicalTimeDouble.h?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libRTI/ieee1516-2010/HandleImplementation.h?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libRTI/ieee1516-2010/RTIHandleFactory.cpp?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libRTI/ieee1516-2010/Handle.cpp?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libRTI/ieee1516-2010/Exception.cpp?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libRTI/ieee1516-2010/RTIvariableLengthDataImplementation.h?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libRTI/ieee1516-2010/RTI1516fedTime.cpp?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libRTI/ieee1516-2010/LogicalTimeDouble.cpp?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libRTI/ieee1516-2010/RTIHandleFactory.h?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libRTI/ieee1516-2010/HandleImplementation.cpp?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/include/ieee1516-2010/RTI/certiLogicalTimeInterval.h?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/include/ieee1516-2010/RTI/certiRTI1516.h?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/include/ieee1516-2010/RTI/certiLogicalTime.h?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/include/ieee1516-2010/RTI/certiLogicalTimeFactory.h?cvsroot=certi&rev=1.1
Patches:
Index: libRTI/ieee1516-2010/RTIvariableLengthData.cpp
===================================================================
RCS file: libRTI/ieee1516-2010/RTIvariableLengthData.cpp
diff -N libRTI/ieee1516-2010/RTIvariableLengthData.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libRTI/ieee1516-2010/RTIvariableLengthData.cpp 3 Mar 2014 16:43:25
-0000 1.1
@@ -0,0 +1,202 @@
+#include <RTI/VariableLengthData.h>
+#include "RTIvariableLengthDataImplementation.h"
+#include <stdlib.h>
+#include <string.h>
+
+namespace rti1516e
+{
+ // ******************************************************
+ // ********* VariableLengthData implementation **********
+ // ******************************************************
+
+ VariableLengthData::VariableLengthData()
+ : _impl(0)
+ {
+ }
+
+ // Caller is free to delete inData after the call
+ VariableLengthData::VariableLengthData(void const * inData, unsigned
long inSize)
+ : _impl(0)
+ {
+ _impl = new VariableLengthDataImplementation(inData, inSize);
+ }
+
+ // Caller is free to delete rhs after the call
+ VariableLengthData::VariableLengthData(VariableLengthData const & rhs)
+ : _impl(0)
+ {
+ _impl = new VariableLengthDataImplementation(*(rhs._impl));
+ }
+
+ VariableLengthData::~VariableLengthData()
+ {
+ delete _impl;
+ }
+
+ VariableLengthData &
+ VariableLengthData::operator=(VariableLengthData const & rhs)
+ {
+ // Beware of self assignment
+ if (this != &rhs)
+ {
+ delete _impl;
+ _impl = new
VariableLengthDataImplementation(*(rhs._impl));
+ }
+
+ return *this;
+ }
+
+ void const *
+ VariableLengthData::data() const
+ {
+ if (_impl != 0)
+ {
+ return _impl->getData();
+ } else
+ {
+ return 0;
+ }
+ }
+ unsigned long
+ VariableLengthData::size() const
+ {
+ if (_impl != 0)
+ {
+ return _impl->getSize();
+ } else
+ {
+ return 0;
+ }
+ }
+
+ // Caller is free to delete inData after the call
+ void VariableLengthData::setData(void const * inData, unsigned long
inSize)
+ {
+ if (_impl != 0)
+ {
+ _impl->setData(inData, inSize);
+ } else
+ {
+ _impl = new VariableLengthDataImplementation(inData,
inSize);
+ }
+ }
+
+ // Caller is responsible for ensuring that the data that is
+ // pointed to is valid for the lifetime of this object, or past
+ // the next time this object is given new data.
+ void VariableLengthData::setDataPointer(void* inData, unsigned long
inSize)
+ {
+ if (_impl == 0)
+ {
+ _impl = new VariableLengthDataImplementation();
+ }
+ _impl->setDataPointer(inData, inSize);
+ }
+
+ // Caller gives up ownership of inData to this object.
+ // This object assumes the responsibility of deleting inData
+ // when it is no longer needed.
+ void VariableLengthData::takeDataPointer(void* inData, unsigned long
inSize)
+ {
+ if (_impl == 0)
+ {
+ _impl = new VariableLengthDataImplementation();
+ }
+ _impl->takeDataPointer(inData, inSize);
+ }
+
+ // ********************************************************************
+ // ********* VariableLengthDataImplementation implementation **********
+ // ********************************************************************
+
+ VariableLengthDataImplementation::VariableLengthDataImplementation()
+ : _data(0)
+ , _size(0)
+ , _dataOwner(false)
+ {
+ }
+
+ // Caller is free to delete inData after the call
+ VariableLengthDataImplementation::VariableLengthDataImplementation(void
const * inData, unsigned long inSize)
+ : _data(0)
+ , _size(inSize)
+ , _dataOwner(true)
+ {
+ _data = malloc(inSize+1);
+ memcpy(_data, inData, _size);
+ }
+
+ // Caller is free to delete rhs after the call
+
VariableLengthDataImplementation::VariableLengthDataImplementation(VariableLengthDataImplementation
const & rhs)
+ : _data(0)
+ , _size(rhs._size)
+ , _dataOwner(true)
+ {
+ _data = malloc(rhs._size);
+ memcpy(_data, rhs._data, _size);
+ }
+
+ VariableLengthDataImplementation::~VariableLengthDataImplementation()
+ {
+ if (_data && _dataOwner)
+ {
+ free(_data);
+ }
+ }
+
+ // Caller is free to delete rhs after the call
+ VariableLengthDataImplementation &
+
VariableLengthDataImplementation::operator=(VariableLengthDataImplementation
const & rhs)
+ {
+ // Beware of self assignment
+ if (this != &rhs)
+ {
+ setData(rhs._data, rhs._size);
+ }
+
+ return *this;
+ }
+
+ // Caller is free to delete inData after the call
+ void VariableLengthDataImplementation::setData(void const * inData,
unsigned long inSize)
+ {
+ if (_data && _dataOwner)
+ {
+ free(_data);
+ }
+ _size = inSize;
+ _dataOwner = true;
+ _data = malloc(_size);
+ memcpy(_data, inData, _size);
+ }
+
+ // Caller is responsible for ensuring that the data that is
+ // pointed to is valid for the lifetime of this object, or past
+ // the next time this object is given new data.
+ void VariableLengthDataImplementation::setDataPointer(void* inData,
unsigned long inSize)
+ {
+ if (_data && _dataOwner)
+ {
+ free(_data);
+ }
+ _size = inSize;
+ _dataOwner = false;
+ _data = inData;
+ }
+
+ // Caller gives up ownership of inData to this object.
+ // This object assumes the responsibility of deleting inData
+ // when it is no longer needed.
+ void VariableLengthDataImplementation::takeDataPointer(void* inData,
unsigned long inSize)
+ {
+ if (_data && _dataOwner)
+ {
+ free(_data);
+ }
+ _size = inSize;
+ _dataOwner = true;
+ _data = inData;
+ }
+
+
+} // end namespace rti1516e
Index: libRTI/ieee1516-2010/LogicalTimeDouble.h
===================================================================
RCS file: libRTI/ieee1516-2010/LogicalTimeDouble.h
diff -N libRTI/ieee1516-2010/LogicalTimeDouble.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libRTI/ieee1516-2010/LogicalTimeDouble.h 3 Mar 2014 16:43:25 -0000
1.1
@@ -0,0 +1,437 @@
+// ----------------------------------------------------------------------------
+// CERTI - HLA RunTime Infrastructure
+// Copyright (C) 2002-2014 ONERA
+//
+// This file is part of CERTI-libRTI
+//
+// CERTI-libRTI is free software ; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public License
+// as published by the Free Software Foundation ; either version 2 of
+// the License, or (at your option) any later version.
+//
+// CERTI-libRTI is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY ; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program ; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA
+//
+// ----------------------------------------------------------------------------
+#ifndef LogicalTimeDouble_h
+#define LogicalTimeDouble_h
+
+#ifdef _WIN32
+#pragma warning(disable:4290)
+#endif
+
+// Standard integer types.
+#ifdef _MSC_VER
+#ifndef FAKED_INTTYPES_DEFINED
+#define FAKED_INTTYPES_DEFINED
+typedef unsigned __int64 uint64_t;
+typedef signed __int64 int64_t;
+typedef unsigned __int32 uint32_t;
+typedef signed __int32 int32_t;
+typedef unsigned __int16 uint16_t;
+typedef signed __int16 int16_t;
+typedef unsigned __int8 uint8_t;
+typedef signed __int8 int8_t;
+typedef short int int_least16_t;
+#endif
+#else
+#include <inttypes.h>
+#endif
+
+#include "RTI/certiLogicalTime.h"
+#include "RTI/certiLogicalTimeInterval.h"
+#include "RTI/certiLogicalTimeFactory.h"
+
+// Microsoft has not implemented the swprintf function according
+// to the ISO C standard. However, they have a function _snwprintf
+// that matches the standardized prototype for swprintf.
+#ifdef _WIN32
+#define swprintf _snwprintf
+#endif
+
+class RTI_EXPORT_FEDTIME LogicalTimeDouble : public rti1516::LogicalTime
+{
+public:
+ LogicalTimeDouble(double value);
+
+ virtual ~LogicalTimeDouble()
+ throw ();
+
+ virtual void setInitial();
+
+ virtual bool isInitial() const;
+
+ virtual void setFinal();
+
+ virtual bool isFinal() const;
+
+ virtual long getSeconds() const;
+ virtual int getMicros() const;
+
+ virtual void setTo(rti1516::LogicalTime const & value)
+ throw (rti1516::InvalidLogicalTime);
+
+ virtual void increaseBy(rti1516::LogicalTimeInterval const & addend)
+ throw (rti1516::IllegalTimeArithmetic,
rti1516::InvalidLogicalTimeInterval);
+
+ virtual void decreaseBy(rti1516::LogicalTimeInterval const & subtrahend)
+ throw (rti1516::IllegalTimeArithmetic,
rti1516::InvalidLogicalTimeInterval);
+
+ virtual std::auto_ptr< rti1516::LogicalTimeInterval >
subtract(rti1516::LogicalTime const & subtrahend) const
+ throw (rti1516::InvalidLogicalTime);
+
+ virtual bool isGreaterThan(rti1516::LogicalTime const & value) const
+ throw (rti1516::InvalidLogicalTime);
+
+ virtual bool isLessThan(rti1516::LogicalTime const & value) const
+ throw (rti1516::InvalidLogicalTime);
+
+ virtual bool isEqualTo(rti1516::LogicalTime const & value) const
+ throw (rti1516::InvalidLogicalTime);
+
+ virtual bool isGreaterThanOrEqualTo(rti1516::LogicalTime const & value)
const
+ throw (rti1516::InvalidLogicalTime);
+
+ virtual bool isLessThanOrEqualTo(rti1516::LogicalTime const & value) const
+ throw (rti1516::InvalidLogicalTime);
+
+ // JvY Begin
+ virtual
+ rti1516::LogicalTime &
+ operator=(rti1516::LogicalTime const & value)
+ throw (rti1516::InvalidLogicalTime);
+
+ virtual
+ LogicalTimeDouble &
+ operator=(LogicalTimeDouble const & value)
+ throw (rti1516::InvalidLogicalTime);
+
+
+ virtual
+ rti1516::LogicalTime &
+ operator+=(rti1516::LogicalTimeInterval const & addend)
+ throw (rti1516::IllegalTimeArithmetic,
rti1516::InvalidLogicalTimeInterval)
+ {
+ increaseBy(addend);
+ return *this;
+ }
+
+ virtual
+ rti1516::LogicalTime &
+ operator-=(rti1516::LogicalTimeInterval const & subtrahend)
+ throw (rti1516::IllegalTimeArithmetic,
rti1516::InvalidLogicalTimeInterval)
+ {
+ decreaseBy(subtrahend);
+ return *this;
+ }
+
+ virtual
+ bool
+ operator>(rti1516::LogicalTime const & value) const
+ throw (rti1516::InvalidLogicalTime)
+ {
+ return isGreaterThan(value);
+ }
+
+ virtual
+ bool
+ operator<(rti1516::LogicalTime const & value) const
+ throw (rti1516::InvalidLogicalTime)
+ {
+ return isLessThan(value);
+ }
+
+ virtual
+ bool
+ operator>=(rti1516::LogicalTime const & value) const
+ throw (rti1516::InvalidLogicalTime)
+ {
+ return isGreaterThanOrEqualTo(value);
+ }
+
+ virtual
+ bool
+ operator<=(rti1516::LogicalTime const & value) const
+ throw (rti1516::InvalidLogicalTime)
+ {
+ return isLessThanOrEqualTo(value);
+ }
+
+ // Generates an encoded value that can be used to send
+ // LogicalTimes to other federates in updates or interactions
+ virtual rti1516::VariableLengthData encode() const;
+
+ // Alternate encode for directly filling a buffer
+ virtual unsigned long encodedLength() const;
+ virtual unsigned long encode(void* buffer, unsigned long bufferSize) const
+ throw (rti1516::CouldNotEncode);
+
+ // Decode encodedLogicalTime into self
+ virtual void decode(rti1516::VariableLengthData const & encodedLogicalTime)
+ throw (rti1516::InternalError,
+ rti1516::CouldNotDecode);
+
+ // Alternate decode that reads directly from a buffer
+ virtual void decode(void* buffer, unsigned long bufferSize)
+ throw (rti1516::InternalError,
+ rti1516::CouldNotDecode);
+
+ // Returns the name of the implementation, as needed by
+ // createFederationExecution.
+ virtual std::wstring implementationName() const
+ {
+ return L"BITS_LogicalTimeDouble";
+ }
+
+ // JvY End
+
+ //virtual std::auto_ptr< rti1516::EncodedLogicalTime > encode() const;
+
+ virtual std::wstring toString() const;
+
+ virtual bool operator==(LogicalTime const & left) const
+ throw (rti1516::InvalidLogicalTime);
+
+ virtual int64_t toMilliseconds() const;
+
+private:
+ explicit LogicalTimeDouble(int64_t value);
+
+ int64_t _value;
+
+ friend class LogicalTimeDoubleFactory;
+ friend class LogicalTimeFactoryDouble;
+};
+
+class RTI_EXPORT_FEDTIME LogicalTimeIntervalDouble : public
rti1516::LogicalTimeInterval
+{
+public:
+ LogicalTimeIntervalDouble(double value);
+
+ virtual ~LogicalTimeIntervalDouble()
+ throw ();
+
+ virtual void setZero();
+
+ virtual bool isZero() const;
+
+ virtual void setEpsilon();
+
+ virtual bool isEpsilon() const;
+
+ virtual long getSeconds() const;
+ virtual int getMicros() const;
+
+ virtual void setTo(rti1516::LogicalTimeInterval const & value)
+ throw (rti1516::InvalidLogicalTimeInterval);
+
+ virtual std::auto_ptr< rti1516::LogicalTimeInterval >
subtract(rti1516::LogicalTimeInterval const & subtrahend) const
+ throw (rti1516::InvalidLogicalTimeInterval);
+
+ virtual bool isGreaterThan(rti1516::LogicalTimeInterval const & value) const
+ throw (rti1516::InvalidLogicalTimeInterval);
+
+ virtual bool isLessThan(rti1516::LogicalTimeInterval const & value) const
+ throw (rti1516::InvalidLogicalTimeInterval);
+
+ virtual bool isEqualTo(rti1516::LogicalTimeInterval const & value) const
+ throw (rti1516::InvalidLogicalTimeInterval);
+
+ virtual bool isGreaterThanOrEqualTo(rti1516::LogicalTimeInterval const &
value) const
+ throw (rti1516::InvalidLogicalTimeInterval);
+
+ virtual bool isLessThanOrEqualTo(rti1516::LogicalTimeInterval const &
value) const
+ throw (rti1516::InvalidLogicalTimeInterval);
+
+ //virtual std::auto_ptr< rti1516::EncodedLogicalTimeInterval > encode()
const;
+
+ virtual std::wstring toString() const;
+
+ // JvY Begin
+ virtual
+ LogicalTimeInterval &
+ operator=(rti1516::LogicalTimeInterval const & value)
+ throw (rti1516::InvalidLogicalTimeInterval)
+ {
+ setTo(value);
+ return *this;
+ }
+
+
+ // Set self to the difference between two LogicalTimes
+ virtual
+ void
+ setToDifference(rti1516::LogicalTime const & minuend,
+ rti1516::LogicalTime const& subtrahend)
+ throw (rti1516::InvalidLogicalTime);
+
+ virtual
+ rti1516::LogicalTimeInterval &
+ operator+=(rti1516::LogicalTimeInterval const & addend)
+ throw (rti1516::InvalidLogicalTimeInterval);
+
+ virtual
+ rti1516::LogicalTimeInterval &
+ operator-=(rti1516::LogicalTimeInterval const & subtrahend)
+ throw (rti1516::InvalidLogicalTimeInterval);
+
+ virtual
+ bool
+ operator>(rti1516::LogicalTimeInterval const & value) const
+ throw (rti1516::InvalidLogicalTimeInterval)
+ {
+ return isGreaterThan(value);
+ }
+
+ virtual
+ bool
+ operator<(rti1516::LogicalTimeInterval const & value) const
+ throw (rti1516::InvalidLogicalTimeInterval)
+ {
+ return isLessThan(value);
+ }
+
+ virtual
+ bool
+ operator==(rti1516::LogicalTimeInterval const & value) const
+ throw (rti1516::InvalidLogicalTimeInterval)
+ {
+ return isEqualTo(value);
+ }
+
+ virtual
+ bool
+ operator>=(rti1516::LogicalTimeInterval const & value) const
+ throw (rti1516::InvalidLogicalTimeInterval)
+ {
+ return isGreaterThanOrEqualTo(value);
+ }
+
+ virtual
+ bool
+ operator<=(rti1516::LogicalTimeInterval const & value) const
+ throw (rti1516::InvalidLogicalTimeInterval)
+ {
+ return isLessThanOrEqualTo(value);
+ }
+
+ // Generates an encoded value that can be used to send
+ // LogicalTimeIntervals to other federates in updates or interactions
+ virtual rti1516::VariableLengthData encode() const;
+
+ // Alternate encode for directly filling a buffer
+ virtual unsigned long encodedLength() const;
+ virtual unsigned long encode(void* buffer, unsigned long bufferSize) const
+ throw (rti1516::CouldNotEncode);
+
+ // Decode encodedValue into self
+ virtual void decode(rti1516::VariableLengthData const & encodedValue)
+ throw (rti1516::InternalError,
+ rti1516::CouldNotDecode);
+
+ // Alternate decode that reads directly from a buffer
+ virtual void decode(void* buffer, unsigned long bufferSize)
+ throw (rti1516::InternalError,
+ rti1516::CouldNotDecode);
+
+ // Returns the name of the implementation, as needed by
+ // createFederationExecution.
+ virtual std::wstring implementationName() const
+ {
+ return L"BITS_LogicalTimeIntervalDouble";
+ }
+
+ // JvY End
+
+private:
+ explicit LogicalTimeIntervalDouble(int64_t value);
+
+ int64_t _value;
+
+ friend class LogicalTimeDouble;
+ friend class LogicalTimeDoubleFactory;
+ friend class LogicalTimeFactoryDouble;
+ friend class LogicalTimeIntervalDoubleFactory;
+ friend class LogicalTimeIntervalFactoryDouble;
+};
+
+
+class RTI_EXPORT_FEDTIME LogicalTimeDoubleFactory : public
rti1516::LogicalTimeFactory
+{
+public:
+ virtual ~LogicalTimeDoubleFactory()
+ throw ();
+
+ virtual std::auto_ptr< rti1516::LogicalTime > makeInitial()
+ throw (rti1516::InternalError);
+
+ // Returns a LogicalTime with a value of "initial"
+ virtual
+ std::auto_ptr< rti1516::LogicalTime >
+ makeLogicalTime()
+ throw (rti1516::InternalError)
+ {
+ return makeInitial();
+ }
+
+ // Returns a LogicalTimeInterval with a value of "zero"
+ virtual
+ std::auto_ptr< rti1516::LogicalTimeInterval >
+ makeLogicalTimeInterval()
+ throw (rti1516::InternalError)
+ {
+ return makeZero();
+ }
+
+ virtual std::auto_ptr< rti1516::LogicalTimeInterval > makeZero()
+ throw (rti1516::InternalError);
+
+ virtual std::auto_ptr< rti1516::LogicalTimeInterval > epsilon()
+ throw (rti1516::InternalError);
+
+ //virtual std::auto_ptr< rti1516::LogicalTime >
decode(rti1516::EncodedLogicalTime const & encodedLogicalTime)
+ // throw (rti1516::InternalError, rti1516::CouldNotDecode);
+};
+
+class RTI_EXPORT_FEDTIME LogicalTimeFactoryDouble : public
LogicalTimeDoubleFactory
+{
+public:
+ virtual ~LogicalTimeFactoryDouble()
+ throw ();
+
+};
+
+class RTI_EXPORT_FEDTIME LogicalTimeIntervalDoubleFactory : public
LogicalTimeDoubleFactory
+{
+public:
+ virtual ~LogicalTimeIntervalDoubleFactory()
+ throw ();
+
+};
+
+class RTI_EXPORT_FEDTIME LogicalTimeIntervalFactoryDouble : public
LogicalTimeDoubleFactory
+{
+public:
+ virtual ~LogicalTimeIntervalFactoryDouble()
+ throw ()
+ {
+ }
+
+};
+
+class RTI_EXPORT_FEDTIME LogicalTimeDoubleFactoryFactory : public
rti1516::LogicalTimeFactoryFactory
+{
+public:
+ static std::auto_ptr< rti1516::LogicalTimeFactory >
+ makeLogicalTimeFactory(std::wstring const & implementationName);
+
+};
+
+#endif // LogicalTimeDouble_h
Index: libRTI/ieee1516-2010/HandleImplementation.h
===================================================================
RCS file: libRTI/ieee1516-2010/HandleImplementation.h
diff -N libRTI/ieee1516-2010/HandleImplementation.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libRTI/ieee1516-2010/HandleImplementation.h 3 Mar 2014 16:43:26 -0000
1.1
@@ -0,0 +1,179 @@
+// ----------------------------------------------------------------------------
+// CERTI - HLA RunTime Infrastructure
+// Copyright (C) 2002-2014 ONERA
+//
+// This file is part of CERTI-libRTI
+//
+// CERTI-libRTI is free software ; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public License
+// as published by the Free Software Foundation ; either version 2 of
+// the License, or (at your option) any later version.
+//
+// CERTI-libRTI is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY ; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program ; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA
+//
+// ----------------------------------------------------------------------------
+#ifndef HandleImplementation_h
+#define HandleImplementation_h
+
+#include <RTI/SpecificConfig.h>
+#include <RTI/Exception.h>
+#include <RTI/VariableLengthData.h>
+#include <string>
+
+// TODO Text below should be fixed. (Copied from Handle definition macro.)
+// The following macro is used to define each of the Handle classes
+// that are used by the RTI's API, e.g. AttributeHandle, ParameterHandle, etc.
+// Each kind of handle contains the same set of operators and functions, but
+// each is a separate class for type safety. The encode method can be used to
+// generate an encoded value for a handle, that can be sent to other federates
+// as an attribute or parameter. (Use RTIambassador functions to reconstruct
a
+// handle from an encoded value). RTI implementations contain definitions
+// for each kind of the HandleKindImplementation classes (e.g.
+// AttributeHandleImplementation), but these classes are not needed by
+// federate code.
+
+typedef unsigned long ULong ;
+
+namespace rti1516e
+{
+ class RTI_EXPORT HandleImplementation
+ {
+ protected:
+ /* Constructs an invalid handle */
+ HandleImplementation();
+
+ public:
+ HandleImplementation(HandleImplementation const & rhs);
+
+ explicit
+ HandleImplementation(VariableLengthData const & encodedValue);
+
+ virtual ~HandleImplementation()
+ throw();
+
+ /* Indicates whether this handle is valid */
+ virtual bool isValid() const;
+
+ /* Generate an encoded value that can be used to send */
+ /* handles to other federates in updates or interactions. */
+ virtual VariableLengthData encode() const;
+
+ /* Alternate encode for directly filling a buffer */
+ virtual unsigned long encodedLength() const;
+ virtual unsigned long encode(
+ void* buffer, unsigned long bufferSize) const
+ throw (CouldNotEncode);
+
+ virtual std::wstring toString() const;
+
+ ULong getValue() const
+ { return _value; }
+
+ void setValue(ULong val)
+ { _value = val; }
+
+ protected:
+ ULong _value;
+ };
+}
+
+#define DEFINE_HANDLE_IMPLEMENTATION_CLASS(HandleKind) \
+ \
+/* Each handle class generated by this macro provides the */ \
+/* following interface */ \
+class RTI_EXPORT HandleKind##Implementation : public HandleImplementation \
+{ \
+public: \
+ \
+ /* Constructs an invalid handle */ \
+ HandleKind##Implementation();
\
+
\
+ HandleKind##Implementation(HandleKind##Implementation const & rhs);
\
+
\
+ explicit
\
+ HandleKind##Implementation(VariableLengthData const & encodedValue);
\
+
\
+ virtual ~HandleKind##Implementation()
\
+ throw();
\
+
\
+ HandleKind##Implementation &
\
+ operator=(HandleKind##Implementation const & rhs);
\
+
\
+ /* All invalid handles are equivalent */
\
+ virtual bool operator==(HandleKind##Implementation const & rhs) const;
\
+ virtual bool operator!=(HandleKind##Implementation const & rhs) const;
\
+ virtual bool operator< (HandleKind##Implementation const & rhs) const;
\
+};
\
+
+
+namespace rti1516
+{
+
+// All of the RTI API's Handle classes are defined
+// by invoking the macro above.
+DEFINE_HANDLE_IMPLEMENTATION_CLASS(FederateHandle)
+DEFINE_HANDLE_IMPLEMENTATION_CLASS(ObjectClassHandle)
+DEFINE_HANDLE_IMPLEMENTATION_CLASS(InteractionClassHandle)
+DEFINE_HANDLE_IMPLEMENTATION_CLASS(ObjectInstanceHandle)
+DEFINE_HANDLE_IMPLEMENTATION_CLASS(AttributeHandle)
+DEFINE_HANDLE_IMPLEMENTATION_CLASS(ParameterHandle)
+DEFINE_HANDLE_IMPLEMENTATION_CLASS(DimensionHandle)
+DEFINE_HANDLE_IMPLEMENTATION_CLASS(RegionHandle)
+
+
+class MessageRetractionHandleImplementation : public HandleImplementation
+{
+ public:
+
+ /* Constructs an invalid handle */
+ MessageRetractionHandleImplementation();
+
+
MessageRetractionHandleImplementation(MessageRetractionHandleImplementation
const & rhs);
+
+ explicit
+ MessageRetractionHandleImplementation(VariableLengthData const &
encodedValue);
+
+ virtual ~MessageRetractionHandleImplementation()
+ throw();
+
+ virtual MessageRetractionHandleImplementation &
+ operator=(MessageRetractionHandleImplementation const & rhs);
+
+ /* All invalid handles are equivalent */
+ virtual bool operator==(MessageRetractionHandleImplementation const
& rhs) const;
+ virtual bool operator!=(MessageRetractionHandleImplementation const
& rhs) const;
+ virtual bool operator< (MessageRetractionHandleImplementation const
& rhs) const;
+
+ /* Generate an encoded value that can be used to send */
+ /* handles to other federates in updates or interactions. */
+ virtual VariableLengthData encode() const;
+
+ /* Alternate encode for directly filling a buffer */
+ virtual unsigned long encodedLength() const;
+ virtual unsigned long encode(
+ void* buffer, unsigned long bufferSize) const
+ throw (CouldNotEncode);
+
+ ULong getSerialNum() const
+ { return _serialNum; }
+
+ void setSerialNum(ULong sn)
+ { _serialNum = sn; }
+
+ protected:
+ ULong _serialNum;
+};
+
+
+}
+
+#endif // RTI_HandleImplementation_h
+
Index: libRTI/ieee1516-2010/RTIHandleFactory.cpp
===================================================================
RCS file: libRTI/ieee1516-2010/RTIHandleFactory.cpp
diff -N libRTI/ieee1516-2010/RTIHandleFactory.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libRTI/ieee1516-2010/RTIHandleFactory.cpp 3 Mar 2014 16:43:26 -0000
1.1
@@ -0,0 +1,98 @@
+// ----------------------------------------------------------------------------
+// CERTI - HLA RunTime Infrastructure
+// Copyright (C) 2002-2014 ONERA
+//
+// This file is part of CERTI-libRTI
+//
+// CERTI-libRTI is free software ; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public License
+// as published by the Free Software Foundation ; either version 2 of
+// the License, or (at your option) any later version.
+//
+// CERTI-libRTI is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY ; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program ; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA
+//
+// ----------------------------------------------------------------------------
+#include "RTIHandleFactory.h"
+
+
+#define DECLARE_HANDLE_FRIEND_CLASS(HandleKind)
\
+
\
+ HandleKind HandleKind##Friend::createRTI1516Handle(const certi::Handle &
certiHandle) \
+ {
\
+ HandleKind##Implementation* handleImpl = new
HandleKind##Implementation(); \
+ handleImpl->setValue(certiHandle);
\
+ HandleKind rti1516Handle(handleImpl);
\
+ return rti1516Handle;
\
+ }
\
+
\
+ HandleKind HandleKind##Friend::createRTI1516Handle(const
rti1516e::VariableLengthData & encodedValue)\
+ {
\
+ HandleKind rti1516Handle(encodedValue);
\
+ return rti1516Handle;
\
+ }
\
+
\
+ certi::Handle HandleKind##Friend::toCertiHandle(const HandleKind &
rti1516Handle) \
+ {
\
+ certi::Handle certiHandle;
\
+ if (rti1516Handle.isValid())
\
+ {
\
+ const HandleKind##Implementation* handleImpl =
rti1516Handle.getImplementation(); \
+ certiHandle = handleImpl->getValue();
\
+ } else {
\
+ certiHandle = 0;
\
+ }
\
+ return certiHandle;
\
+ }
\
+
\
+ HandleKind##Friend::HandleKind##Friend() {}
\
+ HandleKind##Friend::~HandleKind##Friend() {}
\
+
+/* end of DECLARE_HANDLE_FRIEND_CLASS */
+
+namespace rti1516e
+{
+
+// All of the RTI API's HandleFriend classes are defined
+// by invoking the macro above.
+DECLARE_HANDLE_FRIEND_CLASS(FederateHandle)
+DECLARE_HANDLE_FRIEND_CLASS(ObjectClassHandle)
+DECLARE_HANDLE_FRIEND_CLASS(InteractionClassHandle)
+DECLARE_HANDLE_FRIEND_CLASS(ObjectInstanceHandle)
+DECLARE_HANDLE_FRIEND_CLASS(AttributeHandle)
+DECLARE_HANDLE_FRIEND_CLASS(ParameterHandle)
+DECLARE_HANDLE_FRIEND_CLASS(DimensionHandle)
+//DECLARE_HANDLE_FRIEND_CLASS(MessageRetractionHandle)
+DECLARE_HANDLE_FRIEND_CLASS(RegionHandle)
+
+MessageRetractionHandle
MessageRetractionHandleFriend::createRTI1516Handle(const certi::Handle &
certiHandle, uint64_t serialNr) {
+ MessageRetractionHandleImplementation* handleImpl = new
MessageRetractionHandleImplementation();
+ handleImpl->setValue(certiHandle);
+ handleImpl->setSerialNum(serialNr);
+ MessageRetractionHandle rti1516Handle(handleImpl);
+ return rti1516Handle;
+}
+MessageRetractionHandle
MessageRetractionHandleFriend::createRTI1516Handle(const
rti1516e::VariableLengthData & encodedValue) {
+ MessageRetractionHandle rti1516Handle(encodedValue);
+ return rti1516Handle;
+}
+certi::EventRetraction
MessageRetractionHandleFriend::createEventRetraction(const
rti1516e::MessageRetractionHandle & messageRetractionHandle) {
+ const MessageRetractionHandleImplementation* handleImpl =
messageRetractionHandle.getImplementation();
+ certi::EventRetraction eventRetraction;
+ eventRetraction.setSendingFederate( handleImpl->getValue() );
+ eventRetraction.setSN( handleImpl->getSerialNum() );
+ return eventRetraction;
+}
+MessageRetractionHandleFriend::MessageRetractionHandleFriend() {}
+MessageRetractionHandleFriend::~MessageRetractionHandleFriend() {}
+
+
+}
+
Index: libRTI/ieee1516-2010/Handle.cpp
===================================================================
RCS file: libRTI/ieee1516-2010/Handle.cpp
diff -N libRTI/ieee1516-2010/Handle.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libRTI/ieee1516-2010/Handle.cpp 3 Mar 2014 16:43:26 -0000 1.1
@@ -0,0 +1,165 @@
+// ----------------------------------------------------------------------------
+// CERTI - HLA RunTime Infrastructure
+// Copyright (C) 2002-2014 ONERA
+//
+// This file is part of CERTI-libRTI
+//
+// CERTI-libRTI is free software ; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public License
+// as published by the Free Software Foundation ; either version 2 of
+// the License, or (at your option) any later version.
+//
+// CERTI-libRTI is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY ; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program ; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA
+//
+// ----------------------------------------------------------------------------
+#include <sstream>
+#include <RTI/Handle.h>
+#include "HandleImplementation.h"
+
+namespace rti1516e
+{
+
+#define DECLARE_HANDLE_CLASS(HandleKind) \
+ \
+ /* Constructs an invalid handle */ \
+ HandleKind::HandleKind() \
+ : _impl(0) \
+ { \
+ } \
+ \
+ HandleKind::HandleKind(HandleKind##Implementation* impl) \
+ : _impl(0) \
+ { \
+ _impl = impl; \
+ } \
+ \
+ HandleKind::HandleKind(VariableLengthData const & encodedValue) \
+ : _impl(0) \
+ { \
+ _impl = new HandleKind##Implementation(encodedValue); \
+ } \
+ \
+ HandleKind::~HandleKind() \
+ throw() \
+ { \
+ delete _impl; \
+ } \
+ \
+ HandleKind::HandleKind(HandleKind const & rhs) \
+ : _impl(0) \
+ { \
+ if ( rhs._impl != 0)
\
+ _impl = new HandleKind##Implementation(*rhs._impl); \
+ } \
+ \
+ HandleKind & \
+ HandleKind::operator=(HandleKind const & rhs) \
+ { \
+ if (this != &rhs) \
+ { \
+ delete _impl; \
+ if ( 0 != rhs._impl ) \
+ _impl = new
HandleKind##Implementation(*(rhs._impl)); \
+ else
\
+ _impl = 0;
\
+ } \
+ return *this; \
+ } \
+ \
+ /* Indicates whether this handle is valid */ \
+ bool HandleKind::isValid() const \
+ { \
+ if (_impl == 0) \
+ return false; \
+ else \
+ return _impl->isValid(); \
+ }
\
+ \
+ /* All invalid handles are equivalent */ \
+ bool HandleKind::operator==(HandleKind const & rhs) const \
+ { \
+ if (_impl == 0 || rhs.getImplementation() == 0)
\
+ return false;
\
+ else
\
+ return ((*_impl)==(*rhs.getImplementation()));
\
+ } \
+ bool HandleKind::operator!=(HandleKind const & rhs) const \
+ { \
+ if (_impl == 0 || rhs.getImplementation() == 0)
\
+ return false;
\
+ else
\
+ return ((*_impl)!=(*rhs.getImplementation()));
\
+ } \
+ bool HandleKind::operator< (HandleKind const & rhs) const \
+ { \
+ if (_impl == 0 || rhs.getImplementation() == 0)
\
+ return false;
\
+ else
\
+ return ((*_impl)<(*rhs.getImplementation()));
\
+ } \
+ \
+ /* Generate an encoded value that can be used to send */ \
+ /* handles to other federates in updates or interactions. */ \
+ VariableLengthData HandleKind::encode() const \
+ { \
+ return _impl->encode(); \
+ } \
+ \
+ /* Alternate encode for directly filling a buffer */ \
+ unsigned long HandleKind::encodedLength() const \
+ { \
+ return _impl->encodedLength(); \
+ } \
+ unsigned long HandleKind::encode( \
+ void* buffer, unsigned long bufferSize) const \
+ throw (CouldNotEncode) \
+ { \
+ return _impl->encode( buffer, bufferSize ); \
+ } \
+ \
+ std::wstring HandleKind::toString() const \
+ {
\
+ if (_impl == NULL) return L"";
\
+ std::wstring implStr = _impl->toString();
\
+ std::wstringstream ss;
\
+ ss << #HandleKind << "_" << implStr;
\
+ return ss.str(); \
+ } \
+ \
+ const HandleKind##Implementation* HandleKind::getImplementation() const
\
+ { \
+ return _impl; \
+ } \
+ \
+ HandleKind##Implementation* HandleKind::getImplementation() \
+ { \
+ return _impl; \
+ } \
+ \
+ /* Output operator for Handles */ \
+ std::wostream & \
+ operator << (std::wostream &str, HandleKind const &h) \
+ { \
+ return str; \
+ } \
+ /* end DECLARE_HANDLE_CLASS */
+
+DECLARE_HANDLE_CLASS(FederateHandle)
+DECLARE_HANDLE_CLASS(ObjectClassHandle)
+DECLARE_HANDLE_CLASS(InteractionClassHandle)
+DECLARE_HANDLE_CLASS(ObjectInstanceHandle)
+DECLARE_HANDLE_CLASS(AttributeHandle)
+DECLARE_HANDLE_CLASS(ParameterHandle)
+DECLARE_HANDLE_CLASS(DimensionHandle)
+DECLARE_HANDLE_CLASS(MessageRetractionHandle)
+DECLARE_HANDLE_CLASS(RegionHandle)
+
+} // end namespace rti1516
Index: libRTI/ieee1516-2010/Exception.cpp
===================================================================
RCS file: libRTI/ieee1516-2010/Exception.cpp
diff -N libRTI/ieee1516-2010/Exception.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libRTI/ieee1516-2010/Exception.cpp 3 Mar 2014 16:43:26 -0000 1.1
@@ -0,0 +1,192 @@
+// ----------------------------------------------------------------------------
+// CERTI - HLA RunTime Infrastructure
+// Copyright (C) 2002-2014 ONERA
+//
+// This file is part of CERTI-libRTI
+//
+// CERTI-libRTI is free software ; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public License
+// as published by the Free Software Foundation ; either version 2 of
+// the License, or (at your option) any later version.
+//
+// CERTI-libRTI is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY ; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program ; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA
+//
+// ----------------------------------------------------------------------------
+
+#include <RTI/Exception.h>
+#include <iostream>
+#include <sstream>
+
+namespace rti1516e
+{
+Exception::Exception()
+{
+}
+
+Exception::Exception(Exception const & rhs)
+{
+ // Nothing to copy...?
+}
+
+Exception::~Exception()
+{
+}
+
+Exception &
+Exception::operator=(Exception const & rhs)
+{
+ // Nothing to copy...?
+ return *this;
+}
+
+std::wostream &
+operator << (std::wostream &stream, Exception const &e)
+{
+ return stream << e.what() << std::endl;
+}
+
+
+#define RTI_EXCEPTION_IMPL(A) \
+ A::A(std::wstring const & message) throw() \
+ : Exception() \
+ , _msg(message) \
+ { } \
+ std::wstring A::what() const throw() \
+ { \
+ std::wstringstream ss; \
+ ss << "rti1516e::" #A ": " << _msg; \
+ return ss.str(); \
+ }
+
+RTI_EXCEPTION_IMPL(AlreadyConnected)
+RTI_EXCEPTION_IMPL(AsynchronousDeliveryAlreadyDisabled)
+RTI_EXCEPTION_IMPL(AsynchronousDeliveryAlreadyEnabled)
+RTI_EXCEPTION_IMPL(AttributeAcquisitionWasNotCanceled)
+RTI_EXCEPTION_IMPL(AttributeAcquisitionWasNotRequested)
+RTI_EXCEPTION_IMPL(AttributeAlreadyBeingAcquired)
+RTI_EXCEPTION_IMPL(AttributeAlreadyBeingChanged)
+RTI_EXCEPTION_IMPL(AttributeAlreadyBeingDivested)
+RTI_EXCEPTION_IMPL(AttributeAlreadyOwned)
+RTI_EXCEPTION_IMPL(AttributeDivestitureWasNotRequested)
+RTI_EXCEPTION_IMPL(AttributeNotDefined)
+RTI_EXCEPTION_IMPL(AttributeNotOwned)
+RTI_EXCEPTION_IMPL(AttributeNotPublished)
+RTI_EXCEPTION_IMPL(AttributeNotRecognized)
+RTI_EXCEPTION_IMPL(AttributeNotSubscribed)
+RTI_EXCEPTION_IMPL(AttributeRelevanceAdvisorySwitchIsOff)
+RTI_EXCEPTION_IMPL(AttributeRelevanceAdvisorySwitchIsOn)
+RTI_EXCEPTION_IMPL(AttributeScopeAdvisorySwitchIsOff)
+RTI_EXCEPTION_IMPL(AttributeScopeAdvisorySwitchIsOn)
+RTI_EXCEPTION_IMPL(BadInitializationParameter)
+RTI_EXCEPTION_IMPL(CallNotAllowedFromWithinCallback)
+RTI_EXCEPTION_IMPL(ConnectionFailed)
+RTI_EXCEPTION_IMPL(CouldNotCreateLogicalTimeFactory)
+RTI_EXCEPTION_IMPL(CouldNotDecode)
+RTI_EXCEPTION_IMPL(CouldNotDiscover)
+RTI_EXCEPTION_IMPL(CouldNotEncode)
+RTI_EXCEPTION_IMPL(CouldNotOpenFDD)
+RTI_EXCEPTION_IMPL(CouldNotOpenMIM)
+RTI_EXCEPTION_IMPL(CouldNotInitiateRestore)
+RTI_EXCEPTION_IMPL(DeletePrivilegeNotHeld)
+RTI_EXCEPTION_IMPL(RequestForTimeConstrainedPending)
+RTI_EXCEPTION_IMPL(NoRequestToEnableTimeConstrainedWasPending)
+RTI_EXCEPTION_IMPL(RequestForTimeRegulationPending)
+RTI_EXCEPTION_IMPL(NoRequestToEnableTimeRegulationWasPending)
+RTI_EXCEPTION_IMPL(NoFederateWillingToAcquireAttribute)
+RTI_EXCEPTION_IMPL(ErrorReadingFDD)
+RTI_EXCEPTION_IMPL(ErrorReadingMIM)
+RTI_EXCEPTION_IMPL(FederateAlreadyExecutionMember)
+RTI_EXCEPTION_IMPL(FederateHandleNotKnown)
+RTI_EXCEPTION_IMPL(FederateHasNotBegunSave)
+RTI_EXCEPTION_IMPL(FederateInternalError)
+RTI_EXCEPTION_IMPL(FederateIsExecutionMember)
+RTI_EXCEPTION_IMPL(FederateNameAlreadyInUse)
+RTI_EXCEPTION_IMPL(FederateNotExecutionMember)
+RTI_EXCEPTION_IMPL(FederateOwnsAttributes)
+RTI_EXCEPTION_IMPL(FederateServiceInvocationsAreBeingReportedViaMOM)
+RTI_EXCEPTION_IMPL(FederateUnableToUseTime)
+RTI_EXCEPTION_IMPL(FederatesCurrentlyJoined)
+RTI_EXCEPTION_IMPL(FederationExecutionAlreadyExists)
+RTI_EXCEPTION_IMPL(FederationExecutionDoesNotExist)
+RTI_EXCEPTION_IMPL(IllegalName)
+RTI_EXCEPTION_IMPL(IllegalTimeArithmetic)
+RTI_EXCEPTION_IMPL(InconsistentFDD)
+RTI_EXCEPTION_IMPL(InteractionClassAlreadyBeingChanged)
+RTI_EXCEPTION_IMPL(InteractionClassNotDefined)
+RTI_EXCEPTION_IMPL(InteractionClassNotPublished)
+RTI_EXCEPTION_IMPL(InteractionClassNotRecognized)
+RTI_EXCEPTION_IMPL(InteractionClassNotSubscribed)
+RTI_EXCEPTION_IMPL(InteractionParameterNotDefined)
+RTI_EXCEPTION_IMPL(InteractionParameterNotRecognized)
+RTI_EXCEPTION_IMPL(InteractionRelevanceAdvisorySwitchIsOff)
+RTI_EXCEPTION_IMPL(InteractionRelevanceAdvisorySwitchIsOn)
+RTI_EXCEPTION_IMPL(InTimeAdvancingState)
+RTI_EXCEPTION_IMPL(InvalidAttributeHandle)
+RTI_EXCEPTION_IMPL(InvalidDimensionHandle)
+RTI_EXCEPTION_IMPL(InvalidFederateHandle)
+RTI_EXCEPTION_IMPL(InvalidInteractionClassHandle)
+RTI_EXCEPTION_IMPL(InvalidLocalSettingsDesignator)
+RTI_EXCEPTION_IMPL(InvalidLogicalTime)
+RTI_EXCEPTION_IMPL(InvalidLogicalTimeInterval)
+RTI_EXCEPTION_IMPL(InvalidLookahead)
+RTI_EXCEPTION_IMPL(InvalidObjectClassHandle)
+RTI_EXCEPTION_IMPL(InvalidOrderName)
+RTI_EXCEPTION_IMPL(InvalidOrderType)
+RTI_EXCEPTION_IMPL(InvalidParameterHandle)
+RTI_EXCEPTION_IMPL(InvalidRangeBound)
+RTI_EXCEPTION_IMPL(InvalidRegion)
+RTI_EXCEPTION_IMPL(InvalidResignAction)
+RTI_EXCEPTION_IMPL(InvalidRegionContext)
+RTI_EXCEPTION_IMPL(InvalidMessageRetractionHandle)
+RTI_EXCEPTION_IMPL(InvalidServiceGroup)
+RTI_EXCEPTION_IMPL(InvalidTransportationName)
+RTI_EXCEPTION_IMPL(InvalidTransportationType)
+RTI_EXCEPTION_IMPL(InvalidUpdateRateDesignator)
+RTI_EXCEPTION_IMPL(JoinedFederateIsNotInTimeAdvancingState)
+RTI_EXCEPTION_IMPL(LogicalTimeAlreadyPassed)
+RTI_EXCEPTION_IMPL(MessageCanNoLongerBeRetracted)
+RTI_EXCEPTION_IMPL(NameNotFound)
+RTI_EXCEPTION_IMPL(NameSetWasEmpty)
+RTI_EXCEPTION_IMPL(NoAcquisitionPending)
+RTI_EXCEPTION_IMPL(NotConnected)
+RTI_EXCEPTION_IMPL(ObjectClassNotDefined)
+RTI_EXCEPTION_IMPL(ObjectClassNotKnown)
+RTI_EXCEPTION_IMPL(ObjectClassNotPublished)
+RTI_EXCEPTION_IMPL(ObjectClassRelevanceAdvisorySwitchIsOff)
+RTI_EXCEPTION_IMPL(ObjectClassRelevanceAdvisorySwitchIsOn)
+RTI_EXCEPTION_IMPL(ObjectInstanceNameInUse)
+RTI_EXCEPTION_IMPL(ObjectInstanceNameNotReserved)
+RTI_EXCEPTION_IMPL(ObjectInstanceNotKnown)
+RTI_EXCEPTION_IMPL(OwnershipAcquisitionPending)
+RTI_EXCEPTION_IMPL(RTIinternalError)
+RTI_EXCEPTION_IMPL(RegionDoesNotContainSpecifiedDimension)
+RTI_EXCEPTION_IMPL(RegionInUseForUpdateOrSubscription)
+RTI_EXCEPTION_IMPL(RegionNotCreatedByThisFederate)
+RTI_EXCEPTION_IMPL(RestoreInProgress)
+RTI_EXCEPTION_IMPL(RestoreNotInProgress)
+RTI_EXCEPTION_IMPL(RestoreNotRequested)
+RTI_EXCEPTION_IMPL(SaveInProgress)
+RTI_EXCEPTION_IMPL(SaveNotInProgress)
+RTI_EXCEPTION_IMPL(SaveNotInitiated)
+RTI_EXCEPTION_IMPL(SpecifiedSaveLabelDoesNotExist)
+RTI_EXCEPTION_IMPL(SynchronizationPointLabelNotAnnounced)
+RTI_EXCEPTION_IMPL(TimeConstrainedAlreadyEnabled)
+RTI_EXCEPTION_IMPL(TimeConstrainedIsNotEnabled)
+RTI_EXCEPTION_IMPL(TimeRegulationAlreadyEnabled)
+RTI_EXCEPTION_IMPL(TimeRegulationIsNotEnabled)
+RTI_EXCEPTION_IMPL(UnableToPerformSave)
+RTI_EXCEPTION_IMPL(UnknownName)
+RTI_EXCEPTION_IMPL(UnsupportedCallbackModel)
+RTI_EXCEPTION_IMPL(InternalError)
+
+#undef RTI_EXCEPTION_IMPL
+
+} // end namespace rti1516e
Index: libRTI/ieee1516-2010/RTIvariableLengthDataImplementation.h
===================================================================
RCS file: libRTI/ieee1516-2010/RTIvariableLengthDataImplementation.h
diff -N libRTI/ieee1516-2010/RTIvariableLengthDataImplementation.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libRTI/ieee1516-2010/RTIvariableLengthDataImplementation.h 3 Mar 2014
16:43:27 -0000 1.1
@@ -0,0 +1,44 @@
+#ifndef RTI_VariableLengthDataImplementation_h
+#define RTI_VariableLengthDataImplementation_h
+
+namespace rti1516e
+{
+class VariableLengthDataImplementation
+{
+public:
+ VariableLengthDataImplementation();
+ // Caller is free to delete inData after the call
+ VariableLengthDataImplementation(void const * inData, unsigned long
inSize);
+ // Caller is free to delete rhs after the call
+ VariableLengthDataImplementation(VariableLengthDataImplementation const &
rhs);
+
+ ~VariableLengthDataImplementation();
+
+ // Caller is free to delete rhs after the call
+ VariableLengthDataImplementation &
+ operator=(VariableLengthDataImplementation const & rhs);
+
+ // Caller is free to delete inData after the call
+ void setData(void const * inData, unsigned long inSize);
+
+ // Caller is responsible for ensuring that the data that is
+ // pointed to is valid for the lifetime of this object, or past
+ // the next time this object is given new data.
+ void setDataPointer(void* inData, unsigned long inSize);
+
+ // Caller gives up ownership of inData to this object.
+ // This object assumes the responsibility of deleting inData
+ // when it is no longer needed.
+ void takeDataPointer(void* inData, unsigned long inSize);
+
+ void const *getData() { return _data; }
+ unsigned long getSize() { return _size; }
+
+private:
+ void *_data;
+ unsigned long _size;
+ bool _dataOwner;
+};
+}
+
+#endif // RTI_VariableLengthDataImplementation_h
Index: libRTI/ieee1516-2010/RTI1516fedTime.cpp
===================================================================
RCS file: libRTI/ieee1516-2010/RTI1516fedTime.cpp
diff -N libRTI/ieee1516-2010/RTI1516fedTime.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libRTI/ieee1516-2010/RTI1516fedTime.cpp 3 Mar 2014 16:43:27 -0000
1.1
@@ -0,0 +1,872 @@
+// ----------------------------------------------------------------------------
+// CERTI - HLA RunTime Infrastructure
+// Copyright (C) 2002-2014 ONERA
+//
+// This file is part of CERTI-libRTI
+//
+// CERTI-libRTI is free software ; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public License
+// as published by the Free Software Foundation ; either version 2 of
+// the License, or (at your option) any later version.
+//
+// CERTI-libRTI is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY ; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program ; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA
+//
+// ----------------------------------------------------------------------------
+
+#include <RTI/certiLogicalTime.h>
+#include <RTI/certiLogicalTimeInterval.h>
+#include <RTI/certiLogicalTimeFactory.h>
+
+#include <limits>
+#include <memory>
+#include <cstdlib>
+#include <cstring>
+
+#include "RTI1516fedTime.h"
+#include "certi.hh"
+
+rti1516e::LogicalTime &
+rti1516e::LogicalTime::operator=(rti1516e::LogicalTime const & value)
+throw (rti1516e::InvalidLogicalTime)
+{
+ throw std::wstring(L"Operator should be overloaded");
+ //throw rti1516e::InvalidLogicalTime(L"Operator should be overloaded");
+}
+
+rti1516e::LogicalTimeInterval &
+rti1516e::LogicalTimeInterval::operator=(rti1516e::LogicalTimeInterval const &
value)
+throw (rti1516e::InvalidLogicalTimeInterval)
+{
+ throw std::wstring(L"Operator should be overloaded");
+ //throw rti1516e::InvalidLogicalTimeInterval(L"Operator should be
overloaded");
+}
+
+
+/////////////////////////////////////////////////////////////
+//------------------- RTI1516fedTime ----------------------//
+/////////////////////////////////////////////////////////////
+
+
+RTI1516fedTime::RTI1516fedTime(double timeVal)
+: _fedTime(timeVal)
+, _zero(0)
+, _epsilon(std::numeric_limits<double>::epsilon())
+, _positiveInfinity(std::numeric_limits<double>::infinity())
+{
+}
+
+RTI1516fedTime::RTI1516fedTime(const RTI1516fedTime &other)
+: _fedTime(other._fedTime)
+, _zero(other._zero)
+, _epsilon(other._epsilon)
+, _positiveInfinity(other._positiveInfinity)
+{
+}
+
+RTI1516fedTime::~RTI1516fedTime()
+throw ()
+{
+}
+
+
+void
+RTI1516fedTime::setInitial()
+{
+ _fedTime = (0);
+ _zero = (0);
+ _epsilon = (std::numeric_limits<double>::epsilon());
+ _positiveInfinity = (std::numeric_limits<double>::infinity());
+}
+
+
+bool
+RTI1516fedTime::isInitial() const
+{
+ return (_fedTime == _zero);
+}
+
+
+void
+RTI1516fedTime::setFinal()
+{
+ _fedTime = (0);
+ _zero = (0);
+ _epsilon = (std::numeric_limits<double>::epsilon());
+ _positiveInfinity = (std::numeric_limits<double>::infinity());
+}
+
+
+bool
+RTI1516fedTime::isFinal() const
+{
+ return (_fedTime == _zero);
+}
+
+
+rti1516e::LogicalTime &
+RTI1516fedTime::operator=(rti1516e::LogicalTime const & value)
+throw (rti1516e::InvalidLogicalTime)
+{
+ if (this != &value)
+ {
+ const RTI1516fedTime * other = dynamic_cast<const RTI1516fedTime
*>(&value);
+ if (other == NULL)
+ {
+#if defined(_WIN32)
+ throw std::wstring(L"Different LogicalTime implementation");
+ //throw rti1516e::InvalidLogicalTime(L"Different LogicalTime
implementation");
+#else
+ //throw rti1516e::InvalidLogicalTime(L"Different LogicalTime
implementation");
+#endif
+ } else
+ {
+ _fedTime = other->_fedTime;
+ _zero = other->_zero;
+ _epsilon = other->_epsilon;
+ _positiveInfinity = other->_positiveInfinity;
+ }
+ }
+
+ return *this;
+}
+
+RTI1516fedTime &
+RTI1516fedTime::operator=(RTI1516fedTime const & other)
+throw ()
+{
+ if (this != &other)
+ {
+ _fedTime = other._fedTime;
+ _zero = other._zero;
+ _epsilon = other._epsilon;
+ _positiveInfinity = other._positiveInfinity;
+ }
+ return *this;
+}
+
+
+rti1516e::LogicalTime &
+RTI1516fedTime::operator+=(rti1516e::LogicalTimeInterval const & value)
+throw (rti1516e::IllegalTimeArithmetic, rti1516e::InvalidLogicalTimeInterval)
+{
+ const RTI1516fedTimeInterval * other = dynamic_cast<const
RTI1516fedTimeInterval *>(&value);
+ if (other == NULL)
+ {
+#if defined(_WIN32)
+ throw std::wstring(L"Different LogicalTime implementation");
+#else
+ //throw rti1516e::InvalidLogicalTime(L"Different LogicalTime
implementation");
+#endif
+ } else
+ {
+ _fedTime += other->getInterval();
+ }
+
+ return *this;
+}
+
+
+rti1516e::LogicalTime &
+RTI1516fedTime::operator-=(rti1516e::LogicalTimeInterval const & value)
+throw (rti1516e::IllegalTimeArithmetic, rti1516e::InvalidLogicalTimeInterval)
+{
+ const RTI1516fedTimeInterval * other = dynamic_cast<const
RTI1516fedTimeInterval *>(&value);
+ if (other == NULL)
+ {
+#if defined(_WIN32)
+ throw std::wstring(L"Different LogicalTime implementation");
+#else
+ //throw rti1516e::InvalidLogicalTime(L"Different LogicalTime
implementation");
+#endif
+ } else
+ {
+ _fedTime -= other->getInterval();
+ }
+
+ return *this;
+}
+
+
+bool
+RTI1516fedTime::operator>(rti1516e::LogicalTime const & value) const
+throw (rti1516e::InvalidLogicalTime)
+{
+ const RTI1516fedTime * other = dynamic_cast<const RTI1516fedTime
*>(&value);
+ if (other == NULL)
+ {
+#if defined(_WIN32)
+ throw std::wstring(L"Different LogicalTime implementation");
+#else
+ //throw rti1516e::InvalidLogicalTime(L"Different LogicalTime
implementation");
+#endif
+ } else
+ {
+ return _fedTime > other->_fedTime;
+ }
+ return false;
+}
+
+
+bool
+RTI1516fedTime::operator<(rti1516e::LogicalTime const & value) const
+throw (rti1516e::InvalidLogicalTime)
+{
+ const RTI1516fedTime * other = dynamic_cast<const RTI1516fedTime
*>(&value);
+ if (other == NULL)
+ {
+#if defined(_WIN32)
+ throw std::wstring(L"Different LogicalTime implementation");
+#else
+ //throw rti1516e::InvalidLogicalTime(L"Different LogicalTime
implementation");
+#endif
+ } else
+ {
+ return _fedTime < other->_fedTime;
+ }
+ return false;
+}
+
+
+bool
+RTI1516fedTime::operator==(rti1516e::LogicalTime const & value) const
+throw (rti1516e::InvalidLogicalTime)
+{
+ const RTI1516fedTime * other = dynamic_cast<const RTI1516fedTime
*>(&value);
+ if (other == NULL)
+ {
+#if defined(_WIN32)
+ throw std::wstring(L"Different LogicalTime implementation");
+#else
+ //throw rti1516e::InvalidLogicalTime(L"Different LogicalTime
implementation");
+#endif
+ } else
+ {
+ // TODO Should use epsilon during comparison
+ return _fedTime == other->_fedTime;
+ }
+ return false;
+}
+
+
+bool
+RTI1516fedTime::operator>=(rti1516e::LogicalTime const & value) const
+throw (rti1516e::InvalidLogicalTime)
+{
+ const RTI1516fedTime * other = dynamic_cast<const RTI1516fedTime
*>(&value);
+ if (other == NULL)
+ {
+#if defined(_WIN32)
+ throw std::wstring(L"Different LogicalTime implementation");
+#else
+ //throw rti1516e::InvalidLogicalTime(L"Different LogicalTime
implementation");
+#endif
+ } else
+ {
+ return _fedTime >= other->_fedTime;
+ }
+ return false;
+}
+
+
+bool
+RTI1516fedTime::operator<=(rti1516e::LogicalTime const & value) const
+throw (rti1516e::InvalidLogicalTime)
+{
+ const RTI1516fedTime * other = dynamic_cast<const RTI1516fedTime
*>(&value);
+ if (other == NULL)
+ {
+#if defined(_WIN32)
+ throw std::wstring(L"Different LogicalTime implementation");
+#else
+ //throw rti1516e::InvalidLogicalTime(L"Different LogicalTime
implementation");
+#endif
+ } else
+ {
+ return _fedTime <= other->_fedTime;
+ }
+ return false;
+}
+
+// Generates an encoded value that can be used to send
+// LogicalTimes to other federates in updates or interactions
+
+rti1516e::VariableLengthData
+RTI1516fedTime::encode() const
+{
+ uint64_t value;
+#ifdef HOST_IS_BIG_ENDIAN
+ memcpy(&value, &_fedTime, sizeof(double));
+#else
+ value = CERTI_ENCODE_DOUBLE_TO_UINT64BE(&_fedTime);
+#endif
+ return rti1516e::VariableLengthData(&value,sizeof(uint64_t));
+}
+
+// Alternate encode for directly filling a buffer
+
+unsigned long
+RTI1516fedTime::encodedLength() const
+{
+ return sizeof(double);
+}
+
+
+unsigned long
+RTI1516fedTime::encode(void* buffer, unsigned long bufferSize) const
+throw (rti1516e::CouldNotEncode)
+{
+ if (bufferSize >= sizeof(double))
+ {
+#ifdef HOST_IS_BIG_ENDIAN
+ memcpy(buffer, &_fedTime, sizeof(double));
+#else
+ uint64_t value;
+ value = CERTI_ENCODE_DOUBLE_TO_UINT64BE(&_fedTime);
+ memcpy(buffer,&value,sizeof(double));
+#endif
+ return sizeof(double);
+ } else
+ {
+#if defined(_WIN32)
+ throw std::wstring(L"Not enough space in buffer to encode
RTI1516fedTime");
+#else
+ return 0;
+ //throw rti1516e::CouldNotEncode(L"Not enough space in buffer to
encode RTI1516fedTime");
+#endif
+ }
+}
+
+// Decode encodedLogicalTime into self
+
+void
+RTI1516fedTime::decode(rti1516e::VariableLengthData const & encodedLogicalTime)
+throw (rti1516e::InternalError,
+ rti1516e::CouldNotDecode)
+ {
+ union ud {
+ double dv;
+ uint64_t uv;
+ } value;
+#ifdef HOST_IS_BIG_ENDIAN
+ memcpy(&(value.uv), encodedLogicalTime.data(), sizeof(double));
+#else
+ value.uv = CERTI_DECODE_DOUBLE_FROM_UINT64BE(encodedLogicalTime.data());
+#endif
+ _fedTime = value.dv;
+ }
+
+// Alternate decode that reads directly from a buffer
+
+void
+RTI1516fedTime::decode(void* buffer, unsigned long bufferSize)
+throw (rti1516e::InternalError,
+ rti1516e::CouldNotDecode)
+ {
+ if (bufferSize >= sizeof(double))
+ {
+ union ud {
+ double dv;
+ uint64_t uv;
+ } value;
+ value.uv = CERTI_DECODE_DOUBLE_FROM_UINT64BE(buffer);
+ _fedTime = value.dv;
+ } else
+ {
+#if defined(_WIN32) && defined(_MSC_VER)
+ throw std::wstring(L"Not enough space in buffer to decode
RTI1516fedTime");
+#else
+ //throw rti1516e::CouldNotEncode(L"Not enough space in buffer to
decode RTI1516fedTime");
+#endif
+ }
+ }
+
+
+std::wstring
+RTI1516fedTime::toString() const
+{
+ std::wstringstream stream;
+
+ stream << _fedTime;
+
+ return stream.str();
+}
+
+// Returns the name of the implementation, as needed by
+// createFederationExecution.
+
+std::wstring
+RTI1516fedTime::implementationName() const
+{
+ static std::wstring implName(L"certiFedTime1516");
+ return implName;
+}
+
+
+/////////////////////////////////////////////////////////////
+//--------------- RTI1516fedTimeInterval ------------------//
+/////////////////////////////////////////////////////////////
+
+RTI1516fedTimeInterval::RTI1516fedTimeInterval(double timeVal)
+: _fedInterval(timeVal)
+, _zero(0)
+, _epsilon(std::numeric_limits<double>::epsilon())
+, _positiveInfinity(std::numeric_limits<double>::infinity())
+{
+}
+
+RTI1516fedTimeInterval::RTI1516fedTimeInterval(const RTI1516fedTimeInterval
&other)
+: _fedInterval(other._fedInterval)
+, _zero(other._zero)
+, _epsilon(other._epsilon)
+, _positiveInfinity(other._positiveInfinity)
+{
+}
+
+
+RTI1516fedTimeInterval::~RTI1516fedTimeInterval()
+throw ()
+{
+}
+
+
+void
+RTI1516fedTimeInterval::setZero()
+{
+ _fedInterval = _zero;
+}
+
+
+bool
+RTI1516fedTimeInterval::isZero() const
+{
+ return _fedInterval == _zero;
+}
+
+
+void
+RTI1516fedTimeInterval::setEpsilon()
+{
+ _epsilon = (std::numeric_limits<double>::epsilon());
+}
+
+
+bool
+RTI1516fedTimeInterval::isEpsilon() const
+{
+
+ return abs(_fedInterval) <= abs(_epsilon);
+}
+
+
+rti1516e::LogicalTimeInterval &
+RTI1516fedTimeInterval::operator=(rti1516e::LogicalTimeInterval const & value)
+throw (rti1516e::InvalidLogicalTimeInterval)
+{
+ if (this != &value)
+ {
+ const RTI1516fedTimeInterval * other = dynamic_cast<const
RTI1516fedTimeInterval *>(&value);
+ if (other == NULL)
+ {
+#if defined(_WIN32) && defined(_MSC_VER)
+ throw std::wstring(L"Different LogicalTimeInterval
implementation");
+#else
+ //throw rti1516e::InvalidLogicalTimeInterval(L"Different
LogicalTimeInterval implementation");
+#endif
+ } else
+ {
+ _fedInterval = other->_fedInterval;
+ _zero = other->_zero;
+ _epsilon = other->_epsilon;
+ _positiveInfinity = other->_positiveInfinity;
+ }
+ }
+
+ return *this;
+}
+
+RTI1516fedTimeInterval &
+RTI1516fedTimeInterval::operator=(RTI1516fedTimeInterval const & other)
+throw ()
+{
+ if (this != &other)
+ {
+ _fedInterval = other._fedInterval;
+ _zero = other._zero;
+ _epsilon = other._epsilon;
+ _positiveInfinity = other._positiveInfinity;
+ }
+ return *this;
+}
+
+
+// Set self to the difference between two LogicalTimes
+
+void
+RTI1516fedTimeInterval::setToDifference(rti1516e::LogicalTime const & minuend,
+ rti1516e::LogicalTime const& subtrahend)
+throw (rti1516e::InvalidLogicalTime)
+{
+ const RTI1516fedTime * val1 = dynamic_cast<const RTI1516fedTime
*>(&minuend);
+ const RTI1516fedTime * val2 = dynamic_cast<const RTI1516fedTime
*>(&subtrahend);
+
+ if (val1 == 0 && val2 == 0)
+ {
+ // Both wrong
+ std::wstring message(L"First and second argument are different
LogicalTime implementations.");
+#if defined(_WIN32) && defined(_MSC_VER)
+ throw message;
+#else
+ //throw rti1516e::InvalidLogicalTime(message);
+#endif
+ } else if (val1 == 0)
+ {
+ // first wrong
+ std::wstring message(L"First argument uses a different LogicalTime
implementations.");
+#if defined(_WIN32) && defined(_MSC_VER)
+ throw message;
+#else
+ //throw rti1516e::InvalidLogicalTime(message);
+#endif
+ } else if (val2 == 0)
+ {
+ // second wrong
+ std::wstring message(L"Second argument uses a different LogicalTime
implementations.");
+#if defined(_WIN32) && defined(_MSC_VER)
+ throw message;
+#else
+ //throw rti1516e::InvalidLogicalTime(message);
+#endif
+ } else
+ {
+ // Both correct
+ // TODO Should handle infinity?
+ _fedInterval = val1->getFedTime() - val2->getFedTime();
+ }
+} /* end of RTI1516fedTimeInterval::setToDifference */
+
+
+rti1516e::LogicalTimeInterval &
+RTI1516fedTimeInterval::operator+=(rti1516e::LogicalTimeInterval const & value)
+throw (rti1516e::InvalidLogicalTimeInterval)
+{
+ const RTI1516fedTimeInterval * other = dynamic_cast<const
RTI1516fedTimeInterval *>(&value);
+ if (other == NULL)
+ {
+#if defined(_WIN32) && defined(_MSC_VER)
+ throw std::wstring(L"Different LogicalTimeInterval implementation");
+#else
+ //throw rti1516e::InvalidLogicalTimeInterval(L"Different
LogicalTimeInterval implementation");
+#endif
+ } else
+ {
+ _fedInterval += other->getInterval();
+ }
+ return *this;
+}
+
+
+rti1516e::LogicalTimeInterval &
+RTI1516fedTimeInterval::operator-=(rti1516e::LogicalTimeInterval const & value)
+throw (rti1516e::InvalidLogicalTimeInterval)
+{
+ const RTI1516fedTimeInterval * other = dynamic_cast<const
RTI1516fedTimeInterval *>(&value);
+ if (other == NULL)
+ {
+#if defined(_WIN32) && defined(_MSC_VER)
+ throw std::wstring(L"Different LogicalTimeInterval implementation");
+#else
+ //throw rti1516e::InvalidLogicalTimeInterval(L"Different
LogicalTimeInterval implementation");
+#endif
+ } else
+ {
+ _fedInterval -= other->getInterval();
+ }
+ return *this;
+}
+
+
+bool
+RTI1516fedTimeInterval::operator>(rti1516e::LogicalTimeInterval const & value)
const
+throw (rti1516e::InvalidLogicalTimeInterval)
+{
+ const RTI1516fedTimeInterval * other = dynamic_cast<const
RTI1516fedTimeInterval *>(&value);
+ if (other == NULL)
+ {
+#if defined(_WIN32) && defined(_MSC_VER)
+ throw std::wstring(L"Different LogicalTimeInterval implementation");
+#else
+ //throw rti1516e::InvalidLogicalTimeInterval(L"Different
LogicalTimeInterval implementation");
+#endif
+ } else
+ {
+ return getInterval() > other->getInterval();
+ }
+ return false;
+} /* end of RTI1516fedTimeInterval::operator> */
+
+
+bool
+RTI1516fedTimeInterval::operator<(rti1516e::LogicalTimeInterval const & value)
const
+throw (rti1516e::InvalidLogicalTimeInterval)
+{
+ const RTI1516fedTimeInterval * other = dynamic_cast<const
RTI1516fedTimeInterval *>(&value);
+ if (other == NULL)
+ {
+#if defined(_WIN32) && defined(_MSC_VER)
+ throw std::wstring(L"Different LogicalTimeInterval implementation");
+#else
+ //throw rti1516e::InvalidLogicalTimeInterval(L"Different
LogicalTimeInterval implementation");
+#endif
+ } else
+ {
+ return getInterval() > other->getInterval();
+ }
+ return false;
+}
+
+
+bool
+RTI1516fedTimeInterval::operator==(rti1516e::LogicalTimeInterval const &
value) const
+throw (rti1516e::InvalidLogicalTimeInterval)
+{
+ const RTI1516fedTimeInterval * other = dynamic_cast<const
RTI1516fedTimeInterval *>(&value);
+ if (other == NULL)
+ {
+#if defined(_WIN32) && defined(_MSC_VER)
+ throw std::wstring(L"Different LogicalTimeInterval implementation");
+#else
+ //throw rti1516e::InvalidLogicalTimeInterval(L"Different
LogicalTimeInterval implementation");
+#endif
+ } else
+ {
+ return getInterval() == other->getInterval();
+ }
+ return false;
+}
+
+
+bool
+RTI1516fedTimeInterval::operator>=(rti1516e::LogicalTimeInterval const &
value) const
+throw (rti1516e::InvalidLogicalTimeInterval)
+{
+ const RTI1516fedTimeInterval * other = dynamic_cast<const
RTI1516fedTimeInterval *>(&value);
+ if (other == NULL)
+ {
+#if defined(_WIN32) && defined(_MSC_VER)
+ throw std::wstring(L"Different LogicalTimeInterval implementation");
+#else
+ //throw rti1516e::InvalidLogicalTimeInterval(L"Different
LogicalTimeInterval implementation");
+#endif
+ } else
+ {
+ return getInterval() >= other->getInterval();
+ }
+ return false;
+}
+
+
+bool
+RTI1516fedTimeInterval::operator<=(rti1516e::LogicalTimeInterval const &
value) const
+throw (rti1516e::InvalidLogicalTimeInterval)
+{
+ const RTI1516fedTimeInterval * other = dynamic_cast<const
RTI1516fedTimeInterval *>(&value);
+ if (other == NULL)
+ {
+#if defined(_WIN32) && defined(_MSC_VER)
+ throw std::wstring(L"Different LogicalTimeInterval implementation");
+#else
+ //throw rti1516e::InvalidLogicalTimeInterval(L"Different
LogicalTimeInterval implementation");
+#endif
+ } else
+ {
+ return getInterval() <= other->getInterval();
+ }
+ return false;
+}
+
+// Generates an encoded value that can be used to send
+// LogicalTimeIntervals to other federates in updates or interactions
+
+rti1516e::VariableLengthData
+RTI1516fedTimeInterval::encode() const
+{
+ uint64_t value;
+#ifdef HOST_IS_BIG_ENDIAN
+ memcpy(&value, &_fedTime, sizeof(double));
+#else
+ value = CERTI_ENCODE_DOUBLE_TO_UINT64BE(&_fedInterval);
+#endif
+ return rti1516e::VariableLengthData(&value,sizeof(uint64_t));
+}
+
+// Alternate encode for directly filling a buffer
+
+unsigned long
+RTI1516fedTimeInterval::encodedLength() const
+{
+ return sizeof(double);
+}
+
+
+unsigned long
+RTI1516fedTimeInterval::encode(void* buffer, unsigned long bufferSize) const
+throw (rti1516e::CouldNotEncode)
+{
+ if (bufferSize >= sizeof(double))
+ {
+#ifdef HOST_IS_BIG_ENDIAN
+ memcpy(buffer, &_fedInterval, sizeof(double));
+#else
+ uint64_t value;
+ value = CERTI_ENCODE_DOUBLE_TO_UINT64BE(&_fedInterval);
+ memcpy(buffer,&value,sizeof(double));
+#endif
+ return sizeof(double);
+ } else
+ {
+#if defined(_WIN32) && defined(_MSC_VER)
+ throw std::wstring(L"Not enough space in buffer to encode
RTI1516fedTimeInterval");
+#else
+ //throw rti1516e::CouldNotEncode(L"Not enough space in buffer to
encode RTI1516fedTimeInterval");
+#endif
+ }
+ return false;
+}
+
+// Decode encodedValue into self
+
+void
+RTI1516fedTimeInterval::decode(rti1516e::VariableLengthData const &
encodedValue)
+throw (rti1516e::InternalError, rti1516e::CouldNotDecode)
+{
+ union ud {
+ double dv;
+ uint64_t uv;
+ } value;
+#ifdef HOST_IS_BIG_ENDIAN
+ memcpy(&(value.uv), encodedValue.data(), sizeof(double));
+#else
+ value.uv = CERTI_DECODE_DOUBLE_FROM_UINT64BE(encodedValue.data());
+#endif
+ _fedInterval = value.dv;
+}
+
+// Alternate decode that reads directly from a buffer
+
+void
+RTI1516fedTimeInterval::decode(void* buffer, unsigned long bufferSize)
+throw (rti1516e::InternalError, rti1516e::CouldNotDecode)
+{
+ if (bufferSize >= sizeof(double))
+ {
+ union ud {
+ double dv;
+ uint64_t uv;
+ } value;
+ value.uv = CERTI_DECODE_DOUBLE_FROM_UINT64BE(buffer);
+ _fedInterval = value.dv;
+ } else
+ {
+#if defined(_WIN32) && defined(_MSC_VER)
+ throw std::wstring(L"Not enough space in buffer to decode
RTI1516fedTimeInterval");
+#else
+ //throw rti1516e::CouldNotEncode(L"Not enough space in buffer to
decode RTI1516fedTimeInterval");
+#endif
+ }
+}
+
+
+std::wstring
+RTI1516fedTimeInterval::toString() const
+{
+ std::wstringstream stream;
+ stream << _fedInterval;
+
+ return stream.str();
+}
+
+// Returns the name of the implementation, as needed by
+// createFederationExecution.
+
+std::wstring
+RTI1516fedTimeInterval::implementationName() const
+{
+ static std::wstring implName(L"certiFedTime1516");
+ return implName;
+}
+
+
+/////////////////////////////////////////////////////////////
+//---------------- RTI1516fedTimeFactory ------------------//
+/////////////////////////////////////////////////////////////
+
+RTI1516fedTimeFactory::RTI1516fedTimeFactory()
+throw ()
+{
+}
+
+
+RTI1516fedTimeFactory::~RTI1516fedTimeFactory()
+throw ()
+{
+}
+
+// Returns a LogicalTime with a value of "initial"
+
+std::auto_ptr< rti1516e::LogicalTime >
+RTI1516fedTimeFactory::makeLogicalTime()
+throw (rti1516e::InternalError)
+{
+ RTI1516fedTime *fedTime = new RTI1516fedTime(0);
+
+ return std::auto_ptr< rti1516e::LogicalTime >(fedTime);
+}
+
+
+std::auto_ptr< rti1516e::LogicalTime >
+RTI1516fedTimeFactory::makeLogicalTime(double timeVal)
+throw (rti1516e::InternalError)
+{
+ RTI1516fedTime *fedTime = new RTI1516fedTime(timeVal);
+
+ return std::auto_ptr< rti1516e::LogicalTime >(fedTime);
+}
+
+// Returns a LogicalTimeInterval with a value of "zero"
+
+std::auto_ptr< rti1516e::LogicalTimeInterval >
+RTI1516fedTimeFactory::makeLogicalTimeInterval()
+throw (rti1516e::InternalError)
+{
+ RTI1516fedTimeInterval *fedTimeInterval = new RTI1516fedTimeInterval(0);
+
+ return std::auto_ptr< rti1516e::LogicalTimeInterval >(fedTimeInterval);
+}
+
+
+std::auto_ptr< rti1516e::LogicalTimeInterval >
+RTI1516fedTimeFactory::makeLogicalTimeInterval(double timeInterval)
+throw (rti1516e::InternalError)
+{
+ RTI1516fedTimeInterval *fedTimeInterval = new
RTI1516fedTimeInterval(timeInterval);
+
+ return std::auto_ptr< rti1516e::LogicalTimeInterval >(fedTimeInterval);
+}
+
+
+
+std::auto_ptr< rti1516e::LogicalTimeFactory >
+rti1516e::LogicalTimeFactoryFactory::makeLogicalTimeFactory(std::wstring const
& implementationName)
+{
+ RTI1516fedTimeFactory *fedTimeFactory = new RTI1516fedTimeFactory();
+
+ return std::auto_ptr< rti1516e::LogicalTimeFactory >(fedTimeFactory);
+}
Index: libRTI/ieee1516-2010/LogicalTimeDouble.cpp
===================================================================
RCS file: libRTI/ieee1516-2010/LogicalTimeDouble.cpp
diff -N libRTI/ieee1516-2010/LogicalTimeDouble.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libRTI/ieee1516-2010/LogicalTimeDouble.cpp 3 Mar 2014 16:43:27 -0000
1.1
@@ -0,0 +1,755 @@
+// ----------------------------------------------------------------------------
+// CERTI - HLA RunTime Infrastructure
+// Copyright (C) 2002-2014 ONERA
+//
+// This file is part of CERTI-libRTI
+//
+// CERTI-libRTI is free software ; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public License
+// as published by the Free Software Foundation ; either version 2 of
+// the License, or (at your option) any later version.
+//
+// CERTI-libRTI is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY ; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program ; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA
+//
+// ----------------------------------------------------------------------------
+#ifdef _WIN32
+#pragma warning(disable : 4786)
+#pragma warning(disable:4290)
+#endif
+
+#include "RTI/certiRTI1516.h"
+//#include "RTI/EncodedLogicalTime.h"
+//#include "RTI/EncodedLogicalTimeInterval.h"
+
+#include "LogicalTimeDouble.h"
+
+#include <cmath>
+#include <climits>
+#include <typeinfo>
+
+/*
+namespace
+{
+ class MyEncodedLogicalTime : public rti1516::EncodedLogicalTime
+ {
+ private:
+ rti1516::VariableLengthValueClass _value;
+ void* _data;
+ size_t _size;
+ public:
+ MyEncodedLogicalTime(const void* data, size_t size) :
+ _value(data, size)
+ {
+ }
+ virtual ~MyEncodedLogicalTime() throw () {}
+
+ virtual void const * data() const
+ {
+ return _value.data();
+ }
+ virtual size_t size() const
+ {
+ return _value.size();
+ }
+ };
+
+ class MyEncodedLogicalTimeInterval : public
rti1516::EncodedLogicalTimeInterval
+ {
+ private:
+ rti1516::VariableLengthValueClass _value;
+ void* _data;
+ size_t _size;
+ public:
+ MyEncodedLogicalTimeInterval(const void* data, size_t size) :
+ _value(data, size)
+ {
+ }
+ virtual ~MyEncodedLogicalTimeInterval() throw () {}
+
+ virtual void const * data() const
+ {
+ return _value.data();
+ }
+ virtual size_t size() const
+ {
+ return _value.size();
+ }
+ };
+}
+*/
+
+#ifdef __GNUC__
+const int64_t MAX_VALUE = LONG_LONG_MAX;
+#else
+const int64_t MAX_VALUE = 9223372036854775807;
+#endif
+const int64_t MULTIPLIER = 1000000;
+
+LogicalTimeDouble::LogicalTimeDouble(double value)
+{
+ int64_t seconds = (long)floor(value);
+ int64_t micros = (long)fmod(value * MULTIPLIER, (double)MULTIPLIER);
+
+ _value = seconds * MULTIPLIER + micros;
+}
+
+LogicalTimeDouble::LogicalTimeDouble(int64_t value) :
+ _value(value)
+{
+}
+
+LogicalTimeDouble::~LogicalTimeDouble()
+ throw ()
+{
+}
+
+void LogicalTimeDouble::setInitial()
+{
+ _value = 0;
+}
+
+bool LogicalTimeDouble::isInitial() const
+{
+ return _value == 0;
+}
+
+void LogicalTimeDouble::setFinal()
+{
+ _value = MAX_VALUE;
+}
+
+bool LogicalTimeDouble::isFinal() const
+{
+ return _value == MAX_VALUE;
+}
+
+void LogicalTimeDouble::setTo(rti1516::LogicalTime const & value)
+throw (rti1516::InvalidLogicalTime)
+{
+ try {
+ const LogicalTimeDouble& p = dynamic_cast<const
LogicalTimeDouble&>(value);
+ _value = p._value;
+ } catch (std::bad_cast)
+ {
+ throw std::wstring(L"Invalid LogicalTimeDouble");
+ //throw rti1516::InvalidLogicalTime(L"Invalid
LogicalTimeDouble");
+ }
+}
+
+rti1516::LogicalTime &
+LogicalTimeDouble::operator=(rti1516::LogicalTime const & value)
+throw (rti1516::InvalidLogicalTime)
+{
+ setTo(value);
+ return *this;
+}
+
+LogicalTimeDouble &
+LogicalTimeDouble::operator=(LogicalTimeDouble const & value)
+throw (rti1516::InvalidLogicalTime)
+{
+ setTo(value);
+ return *this;
+}
+
+
+
+
+
+void LogicalTimeDouble::increaseBy(rti1516::LogicalTimeInterval const & addend)
+throw (rti1516::IllegalTimeArithmetic, rti1516::InvalidLogicalTimeInterval)
+{
+ try {
+ const LogicalTimeIntervalDouble& p = dynamic_cast<const
LogicalTimeIntervalDouble&>(addend);
+ _value += p._value;
+ } catch (std::bad_cast)
+ {
+ throw std::wstring(L"Invalid LogicalTimeDouble");
+ //throw rti1516::InvalidLogicalTimeInterval(L"Invalid
LogicalTimeDouble");
+ }
+}
+
+void LogicalTimeDouble::decreaseBy(rti1516::LogicalTimeInterval const &
subtrahend)
+throw (rti1516::IllegalTimeArithmetic, rti1516::InvalidLogicalTimeInterval)
+{
+ try {
+ const LogicalTimeIntervalDouble& p = dynamic_cast<const
LogicalTimeIntervalDouble&>(subtrahend);
+ _value -= p._value;
+ } catch (std::bad_cast)
+ {
+ throw std::wstring(L"Invalid LogicalTimeDouble");
+ //throw rti1516::InvalidLogicalTimeInterval(L"Invalid
LogicalTimeDouble");
+ }
+
+}
+
+std::auto_ptr< rti1516::LogicalTimeInterval >
LogicalTimeDouble::subtract(rti1516::LogicalTime const & subtrahend) const
+throw (rti1516::InvalidLogicalTime)
+{
+ try {
+ const LogicalTimeDouble& p = dynamic_cast<const
LogicalTimeDouble&>(subtrahend);
+ return std::auto_ptr< rti1516::LogicalTimeInterval >(new
LogicalTimeIntervalDouble(_value - p._value));
+ } catch (std::bad_cast)
+ {
+ throw std::wstring(L"Invalid LogicalTimeDouble");
+ //throw rti1516::InvalidLogicalTime(L"Invalid
LogicalTimeDouble");
+ }
+}
+
+bool LogicalTimeDouble::isGreaterThan(rti1516::LogicalTime const & value) const
+throw (rti1516::InvalidLogicalTime)
+{
+ try {
+ const LogicalTimeDouble& p = dynamic_cast<const
LogicalTimeDouble&>(value);
+ return _value > p._value;
+ } catch (std::bad_cast)
+ {
+ throw std::wstring(L"Invalid LogicalTimeDouble");
+ //throw rti1516::InvalidLogicalTime(L"Invalid
LogicalTimeDouble");
+ }
+}
+
+bool LogicalTimeDouble::isLessThan(rti1516::LogicalTime const & value) const
+throw (rti1516::InvalidLogicalTime)
+{
+ try {
+ const LogicalTimeDouble& p = dynamic_cast<const
LogicalTimeDouble&>(value);
+ return _value < p._value;
+ } catch (std::bad_cast)
+ {
+ throw std::wstring(L"Invalid LogicalTimeDouble");
+ //throw rti1516::InvalidLogicalTime(L"Invalid
LogicalTimeDouble");
+ }
+}
+
+bool LogicalTimeDouble::isEqualTo(rti1516::LogicalTime const & value) const
+throw (rti1516::InvalidLogicalTime)
+{
+ try {
+ const LogicalTimeDouble& p = dynamic_cast<const
LogicalTimeDouble&>(value);
+ return _value == p._value;
+ } catch (std::bad_cast)
+ {
+ throw std::wstring(L"Invalid LogicalTimeDouble");
+ //throw rti1516::InvalidLogicalTime(L"Invalid
LogicalTimeDouble");
+ }
+}
+
+bool LogicalTimeDouble::isGreaterThanOrEqualTo(rti1516::LogicalTime const &
value) const
+throw (rti1516::InvalidLogicalTime)
+{
+ try {
+ const LogicalTimeDouble& p = dynamic_cast<const
LogicalTimeDouble&>(value);
+ return _value >= p._value;
+ } catch (std::bad_cast)
+ {
+ throw std::wstring(L"Invalid LogicalTimeDouble");
+ //throw rti1516::InvalidLogicalTime(L"Invalid
LogicalTimeDouble");
+ }
+}
+
+bool LogicalTimeDouble::isLessThanOrEqualTo(rti1516::LogicalTime const &
value) const
+throw (rti1516::InvalidLogicalTime)
+{
+ try {
+ const LogicalTimeDouble& p = dynamic_cast<const
LogicalTimeDouble&>(value);
+ return _value <= p._value;
+ } catch (std::bad_cast)
+ {
+ throw std::wstring(L"Invalid LogicalTimeDouble");
+ //throw rti1516::InvalidLogicalTime(L"Invalid
LogicalTimeDouble");
+ }
+}
+
+long LogicalTimeDouble::getSeconds() const
+{
+ return (long)(_value / MULTIPLIER);
+}
+
+int LogicalTimeDouble::getMicros() const
+{
+ return (int)(_value % MULTIPLIER);
+}
+
+std::wstring LogicalTimeDouble::toString() const
+{
+ wchar_t buf[128];
+ if (_value == MAX_VALUE) {
+ swprintf(buf, 128, L"LogicalTimeDouble<INF>");
+ } else {
+ swprintf(buf, 128, L"LogicalTimeDouble<%d.%06d>", getSeconds(),
getMicros());
+ }
+ return buf;
+}
+
+bool LogicalTimeDouble::operator==(LogicalTime const & lt_left) const
+ throw (rti1516::InvalidLogicalTime)
+{
+ try {
+ const LogicalTimeDouble& left = dynamic_cast<const
LogicalTimeDouble&>(lt_left);
+ return (((left._value - 1000) < _value) && ((left._value +
1000) > _value));
+ } catch (std::bad_cast)
+ {
+ throw std::wstring(L"Invalid LogicalTimeDouble");
+ //throw rti1516::InvalidLogicalTime(L"Invalid
LogicalTimeDouble");
+ }
+}
+
+int64_t LogicalTimeDouble::toMilliseconds() const
+{
+ return _value/1000;
+}
+
+rti1516::VariableLengthData LogicalTimeDouble::encode() const
+{
+ unsigned char buf[sizeof(_value)];
+ int pos = 0;
+ buf[pos++] = (unsigned char)((_value >> 56) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 48) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 40) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 32) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 24) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 16) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 8) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 0) & 0xFF);
+
+ rti1516::VariableLengthData varData(buf, pos);
+
+ return varData;
+}
+
+unsigned long LogicalTimeDouble::encodedLength() const
+{
+ return 8L;
+}
+
+unsigned long LogicalTimeDouble::encode(void* buffer, unsigned long
bufferSize) const
+ throw (rti1516::CouldNotEncode)
+{
+ unsigned char *buf = (unsigned char*)buffer;
+ int pos = 0;
+ buf[pos++] = (unsigned char)((_value >> 56) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 48) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 40) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 32) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 24) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 16) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 8) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 0) & 0xFF);
+
+ return 8L;
+}
+
+void LogicalTimeDouble::decode(rti1516::VariableLengthData const &
encodedLogicalTime)
+ throw (rti1516::InternalError, rti1516::CouldNotDecode)
+{
+ int64_t value = 0;
+ unsigned char* buf = (unsigned char*)encodedLogicalTime.data();
+ int pos = 0;
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+
+ _value = value;
+}
+
+void LogicalTimeDouble::decode(void* buffer, unsigned long bufferSize)
+ throw (rti1516::InternalError,
+ rti1516::CouldNotDecode)
+{
+ int64_t value = 0;
+ unsigned char* buf = (unsigned char*)buffer;
+ int pos = 0;
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+
+ _value = value;
+}
+
+///////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////
+
+
+
+
+
+
+
+LogicalTimeDoubleFactory::~LogicalTimeDoubleFactory()
+throw ()
+{
+}
+
+std::auto_ptr< rti1516::LogicalTime > LogicalTimeDoubleFactory::makeInitial()
+ throw (rti1516::InternalError)
+{
+ return std::auto_ptr< rti1516::LogicalTime >(new
LogicalTimeDouble((int64_t)0));
+}
+
+std::auto_ptr< rti1516::LogicalTimeInterval >
LogicalTimeDoubleFactory::makeZero()
+ throw (rti1516::InternalError)
+{
+ return std::auto_ptr< rti1516::LogicalTimeInterval >(new
LogicalTimeIntervalDouble((int64_t)0));
+}
+
+std::auto_ptr< rti1516::LogicalTimeInterval >
LogicalTimeDoubleFactory::epsilon()
+ throw (rti1516::InternalError)
+{
+ return std::auto_ptr< rti1516::LogicalTimeInterval >(new
LogicalTimeIntervalDouble((int64_t)1));
+}
+
+
+LogicalTimeFactoryDouble::~LogicalTimeFactoryDouble()
+throw ()
+{
+}
+
+
+
+///////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////
+
+
+
+
+
+
+LogicalTimeIntervalDouble::LogicalTimeIntervalDouble(double value)
+{
+ int64_t seconds = (long)floor(value);
+ int64_t micros = (long)fmod(value * MULTIPLIER, (double)MULTIPLIER);
+
+ _value = seconds * MULTIPLIER + micros;
+}
+
+LogicalTimeIntervalDouble::LogicalTimeIntervalDouble(int64_t value) :
+ _value(value)
+{
+}
+
+LogicalTimeIntervalDouble::~LogicalTimeIntervalDouble()
+ throw ()
+{
+}
+
+void LogicalTimeIntervalDouble::setZero()
+{
+ _value = 0;
+}
+
+bool LogicalTimeIntervalDouble::isZero() const
+{
+ return _value == 0;
+}
+
+void LogicalTimeIntervalDouble::setEpsilon()
+{
+ _value = 1;
+}
+
+bool LogicalTimeIntervalDouble::isEpsilon() const
+{
+ return _value == 1;
+}
+
+long LogicalTimeIntervalDouble::getSeconds() const
+{
+ return (long)(_value / MULTIPLIER);
+}
+
+int LogicalTimeIntervalDouble::getMicros() const
+{
+ return (int)(_value % MULTIPLIER);
+}
+
+void LogicalTimeIntervalDouble::setTo(rti1516::LogicalTimeInterval const &
value)
+ throw (rti1516::InvalidLogicalTimeInterval)
+{
+ try {
+ const LogicalTimeIntervalDouble& p = dynamic_cast<const
LogicalTimeIntervalDouble&>(value);
+ _value = p._value;
+ } catch (std::bad_cast)
+ {
+ throw rti1516::InvalidLogicalTime(L"Invalid LogicalTimeDouble");
+ }
+}
+
+std::auto_ptr< rti1516::LogicalTimeInterval >
+LogicalTimeIntervalDouble::subtract(rti1516::LogicalTimeInterval const &
subtrahend) const
+ throw (rti1516::InvalidLogicalTimeInterval)
+{
+ const LogicalTimeIntervalDouble& p = dynamic_cast<const
LogicalTimeIntervalDouble&>(subtrahend);
+
+ int64_t d = _value - p._value;
+ if (d < 0) {
+ d = -d;
+ }
+ return std::auto_ptr< rti1516::LogicalTimeInterval >(new
LogicalTimeIntervalDouble(d));
+}
+
+bool LogicalTimeIntervalDouble::isGreaterThan(rti1516::LogicalTimeInterval
const & value) const
+ throw (rti1516::InvalidLogicalTimeInterval)
+{
+ try {
+ const LogicalTimeIntervalDouble& p = dynamic_cast<const
LogicalTimeIntervalDouble&>(value);
+ return _value > p._value;
+ } catch (std::bad_cast)
+ {
+ throw rti1516::InvalidLogicalTime(L"Invalid LogicalTimeDouble");
+ }
+}
+
+bool LogicalTimeIntervalDouble::isLessThan(rti1516::LogicalTimeInterval const
& value) const
+throw (rti1516::InvalidLogicalTimeInterval)
+{
+ try {
+ const LogicalTimeIntervalDouble& p = dynamic_cast<const
LogicalTimeIntervalDouble&>(value);
+ return _value < p._value;
+ } catch (std::bad_cast)
+ {
+ throw rti1516::InvalidLogicalTime(L"Invalid LogicalTimeDouble");
+ }
+}
+
+bool LogicalTimeIntervalDouble::isEqualTo(rti1516::LogicalTimeInterval const &
value) const
+throw (rti1516::InvalidLogicalTimeInterval)
+{
+ try {
+ const LogicalTimeIntervalDouble& p = dynamic_cast<const
LogicalTimeIntervalDouble&>(value);
+ return _value == p._value;
+ } catch (std::bad_cast)
+ {
+ throw rti1516::InvalidLogicalTime(L"Invalid LogicalTimeDouble");
+ }
+}
+
+bool
LogicalTimeIntervalDouble::isGreaterThanOrEqualTo(rti1516::LogicalTimeInterval
const & value) const
+throw (rti1516::InvalidLogicalTimeInterval)
+{
+ try {
+ const LogicalTimeIntervalDouble& p = dynamic_cast<const
LogicalTimeIntervalDouble&>(value);
+ return _value >= p._value;
+ } catch (std::bad_cast)
+ {
+ throw rti1516::InvalidLogicalTime(L"Invalid LogicalTimeDouble");
+ }
+}
+
+bool
LogicalTimeIntervalDouble::isLessThanOrEqualTo(rti1516::LogicalTimeInterval
const & value) const
+throw (rti1516::InvalidLogicalTimeInterval)
+{
+ try {
+ const LogicalTimeIntervalDouble& p = dynamic_cast<const
LogicalTimeIntervalDouble&>(value);
+ return _value <= p._value;
+ } catch (std::bad_cast)
+ {
+ throw rti1516::InvalidLogicalTime(L"Invalid LogicalTimeDouble");
+ }
+}
+
+rti1516::VariableLengthData LogicalTimeIntervalDouble::encode() const
+{
+ unsigned char buf[sizeof(_value)];
+ int pos = 0;
+ buf[pos++] = (unsigned char)((_value >> 56) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 48) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 40) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 32) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 24) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 16) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 8) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 0) & 0xFF);
+
+ rti1516::VariableLengthData varData(buf, pos);
+
+ return varData;
+}
+
+unsigned long
+LogicalTimeIntervalDouble::encodedLength() const
+{
+ return 8L;
+}
+unsigned long
+LogicalTimeIntervalDouble::encode(void* buffer, unsigned long bufferSize) const
+throw (rti1516::CouldNotEncode)
+{
+ if (bufferSize < 8L)
+ {
+ throw rti1516::CouldNotEncode(L"Not enough space to encode
LogicalTimeIntervalDouble");
+ }
+
+ unsigned char *buf = (unsigned char *) buffer;
+ int pos = 0;
+ buf[pos++] = (unsigned char)((_value >> 56) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 48) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 40) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 32) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 24) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 16) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 8) & 0xFF);
+ buf[pos++] = (unsigned char)((_value >> 0) & 0xFF);
+
+ return 8L;
+}
+
+void LogicalTimeIntervalDouble::decode(rti1516::VariableLengthData const &
encodedLogicalTimeInterval)
+throw (rti1516::InternalError, rti1516::CouldNotDecode)
+{
+ if (encodedLogicalTimeInterval.size() < 8L)
+ {
+ throw rti1516::CouldNotDecode(L"Not enough data in
VariableLengthData to decode LogicalTimeIntervalDouble. (Needs 8 bytes)");
+ }
+
+ int64_t value = 0;
+ unsigned char* buf = (unsigned char*)encodedLogicalTimeInterval.data();
+ int pos = 0;
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+
+ _value = value;
+}
+
+
+void
+LogicalTimeIntervalDouble::decode(void* buffer, unsigned long bufferSize)
+throw (rti1516::InternalError,
+ rti1516::CouldNotDecode)
+{
+ if (bufferSize < 8L)
+ {
+ throw rti1516::CouldNotDecode(L"Not enough data in
VariableLengthData to decode LogicalTimeIntervalDouble. (Needs 8 bytes)");
+ }
+ int64_t value = 0;
+ unsigned char* buf = (unsigned char*)buffer;
+ int pos = 0;
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+
+ _value = value;
+}
+
+
+std::wstring LogicalTimeIntervalDouble::toString() const
+{
+ wchar_t buf[128];
+ swprintf(buf, 128, L"LogicalTimeIntervalDouble<%d.%06d>", getSeconds(),
getMicros());
+ return buf;
+}
+
+
+void
+LogicalTimeIntervalDouble::setToDifference(rti1516::LogicalTime const &
minuend,
+
rti1516::LogicalTime const& subtrahend)
+
throw (rti1516::InvalidLogicalTime)
+{
+ try {
+ const LogicalTimeDouble& d_minuend = dynamic_cast<const
LogicalTimeDouble&>(minuend);
+ const LogicalTimeDouble& d_subtrahend = dynamic_cast<const
LogicalTimeDouble&>(subtrahend);
+
+ int64_t value = d_minuend.toMilliseconds() -
d_subtrahend.toMilliseconds();
+ if (value < 0) {
+ value = -value;
+ }
+ _value = value;
+ } catch (std::bad_cast)
+ {
+ throw rti1516::InvalidLogicalTime(L"Invalid LogicalTimeDouble");
+ }
+
+}
+
+rti1516::LogicalTimeInterval &
+LogicalTimeIntervalDouble::operator+=(rti1516::LogicalTimeInterval const &
addend)
+throw (rti1516::InvalidLogicalTimeInterval)
+{
+ return *this;
+}
+
+rti1516::LogicalTimeInterval &
+LogicalTimeIntervalDouble::operator-=(rti1516::LogicalTimeInterval const &
subtrahend)
+throw (rti1516::InvalidLogicalTimeInterval)
+{
+ return *this;
+}
+
+
+
+
+
+
+
+LogicalTimeIntervalDoubleFactory::~LogicalTimeIntervalDoubleFactory()
+ throw ()
+{
+}
+
+
+
+/*
+LogicalTimeIntervalFactoryDouble::~LogicalTimeIntervalFactoryDouble()
+ throw ()
+{
+}
+
+std::auto_ptr< rti1516::LogicalTimeInterval >
LogicalTimeIntervalFactoryDouble::makeZero()
+ throw (rti1516::InternalError)
+{
+ return std::auto_ptr< rti1516::LogicalTimeInterval >(new
LogicalTimeIntervalDouble((int64_t)0));
+}
+
+std::auto_ptr< rti1516::LogicalTimeInterval >
LogicalTimeIntervalFactoryDouble::epsilon()
+ throw (rti1516::InternalError)
+{
+ return std::auto_ptr< rti1516::LogicalTimeInterval >(new
LogicalTimeIntervalDouble((int64_t)1));
+}
+
+std::auto_ptr< rti1516::LogicalTimeInterval >
LogicalTimeIntervalFactoryDouble::decode(rti1516::EncodedLogicalTimeInterval
const & encodedLogicalTimeInterval)
+ // throw (InternalError, CouldNotDecode)
+ throw ()
+{
+ int64_t value = 0;
+ unsigned char* buf = (unsigned char*)encodedLogicalTimeInterval.data();
+ int pos = 0;
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ value = (value << 8) | buf[pos++];
+ return std::auto_ptr< rti1516::LogicalTimeInterval >(new
LogicalTimeIntervalDouble(value));
+}
+*/
Index: libRTI/ieee1516-2010/RTIHandleFactory.h
===================================================================
RCS file: libRTI/ieee1516-2010/RTIHandleFactory.h
diff -N libRTI/ieee1516-2010/RTIHandleFactory.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libRTI/ieee1516-2010/RTIHandleFactory.h 3 Mar 2014 16:43:27 -0000
1.1
@@ -0,0 +1,114 @@
+// ----------------------------------------------------------------------------
+// CERTI - HLA RunTime Infrastructure
+// Copyright (C) 2002-2014 ONERA
+//
+// This file is part of CERTI-libRTI
+//
+// CERTI-libRTI is free software ; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public License
+// as published by the Free Software Foundation ; either version 2 of
+// the License, or (at your option) any later version.
+//
+// CERTI-libRTI is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY ; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program ; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA
+//
+// ----------------------------------------------------------------------------
+#ifndef RTIHandleFactory_h
+#define RTIHandleFactory_h
+
+#include <set>
+#include <map>
+#include <vector>
+#include <list>
+#include "certi.hh"
+#include "GAV.hh"
+#include <RTI/Typedefs.h>
+#include "HandleImplementation.h"
+#include "M_Classes.hh"
+
+
+template<class I>
+struct certi_cast
+{
+ template<class R>
+ const I& operator()(const R& imp)
+ {
+ try {
+ return dynamic_cast<const I&>(imp);
+ }
+ catch (...)
+ {
+ throw rti1516::RTIinternalError(L"Incompatible object on input.");
+ }
+ }
+
+ template<class R>
+ I& operator()(R& imp)
+ {
+ try {
+ return dynamic_cast<I&>(imp);
+ }
+ catch (...)
+ {
+ throw rti1516::RTIinternalError(L"Incompatible object on input.");
+ }
+ }
+};
+
+#define DEFINE_HANDLE_FRIEND_CLASS(HandleKind) \
+
\
+/* Forward declaration for the RTI-internal class */ \
+/* used to implement a specific kind of handle */ \
+class HandleKind;
\
+class HandleKind##Implementation; \
+
\
+/* Each handle class generated by this macro provides the */ \
+/* following interface */ \
+class RTI_EXPORT HandleKind##Friend \
+{ \
+public: \
+ static HandleKind createRTI1516Handle(const certi::Handle & certiHandle);
\
+ static HandleKind createRTI1516Handle(const rti1516e::VariableLengthData &
encodedValue); \
+ static certi::Handle toCertiHandle(const HandleKind & rti1516Handle);
\
+
\
+private: \
+ HandleKind##Friend(); \
+ ~HandleKind##Friend(); \
+
\
+}; \
+
+namespace rti1516e
+{
+
+ // All of the RTI API's HandleFriend classes are defined
+ // by invoking the macro above.
+ DEFINE_HANDLE_FRIEND_CLASS(FederateHandle)
+ DEFINE_HANDLE_FRIEND_CLASS(ObjectClassHandle)
+ DEFINE_HANDLE_FRIEND_CLASS(InteractionClassHandle)
+ DEFINE_HANDLE_FRIEND_CLASS(ObjectInstanceHandle)
+ DEFINE_HANDLE_FRIEND_CLASS(AttributeHandle)
+ DEFINE_HANDLE_FRIEND_CLASS(ParameterHandle)
+ DEFINE_HANDLE_FRIEND_CLASS(DimensionHandle)
+ //DEFINE_HANDLE_FRIEND_CLASS(MessageRetractionHandle)
+ DEFINE_HANDLE_FRIEND_CLASS(RegionHandle)
+
+ class MessageRetractionHandleFriend {
+ public:
+ static MessageRetractionHandle createRTI1516Handle(const
certi::Handle & certiHandle, uint64_t serialNr);
+ static MessageRetractionHandle createRTI1516Handle(const
rti1516e::VariableLengthData & encodedValue);
+ static certi::EventRetraction createEventRetraction(const
rti1516e::MessageRetractionHandle & messageRetractionHandle);
+ private:
+ MessageRetractionHandleFriend();
+ ~MessageRetractionHandleFriend();
+ };
+
+}
+
+#endif // RTI_RTI1516HandleFactory_h
Index: libRTI/ieee1516-2010/HandleImplementation.cpp
===================================================================
RCS file: libRTI/ieee1516-2010/HandleImplementation.cpp
diff -N libRTI/ieee1516-2010/HandleImplementation.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libRTI/ieee1516-2010/HandleImplementation.cpp 3 Mar 2014 16:43:28
-0000 1.1
@@ -0,0 +1,304 @@
+// ----------------------------------------------------------------------------
+// CERTI - HLA RunTime Infrastructure
+// Copyright (C) 2002-2014 ONERA
+//
+// This file is part of CERTI-libRTI
+//
+// CERTI-libRTI is free software ; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public License
+// as published by the Free Software Foundation ; either version 2 of
+// the License, or (at your option) any later version.
+//
+// CERTI-libRTI is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY ; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program ; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA
+//
+// ----------------------------------------------------------------------------
+
+#include <RTI/Handle.h>
+#include <limits.h>
+#include <sstream>
+#include <cstring>
+#include "HandleImplementation.h"
+
+namespace rti1516e
+{
+
+/* Constructs an invalid handle */
+HandleImplementation::HandleImplementation()
+: _value(ULONG_MAX)
+{
+}
+
+HandleImplementation::HandleImplementation(VariableLengthData const &
encodedValue)
+: _value(ULONG_MAX)
+{
+ ULong val = 0;
+ const size_t size = sizeof(val);
+ unsigned char buf[size];
+
+ if (encodedValue.size() != size) {
+ throw CouldNotDecode(L"Encoded value has an unexpected size.");
+ }
+
+ memcpy(&val, encodedValue.data(), size);
+ for(uint32_t i = 0; i < sizeof(val); i++)
+ {
+ buf[size-i-1] = (char) val & 0xFF;
+ val = val >> 8;
+ }
+
+ //copy buffer to _value
+ ULong newValue;
+ memcpy(&newValue, buf, size);
+ _value = newValue;
+}
+
+HandleImplementation::~HandleImplementation()
+throw()
+{
+}
+
+HandleImplementation::HandleImplementation(HandleImplementation const & rhs)
+: _value(ULONG_MAX)
+{
+ _value = rhs._value;
+}
+
+/* Indicates whether this handle is valid */
+bool HandleImplementation::isValid() const
+{
+ if (_value == ULONG_MAX)
+ return false;
+ else
+ return true;
+}
+
+/* Generate an encoded value that can be used to send */
+/* handles to other federates in updates or interactions. */
+VariableLengthData HandleImplementation::encode() const
+{
+ unsigned char buf[sizeof(_value)];
+ encode(buf, sizeof(_value));
+ VariableLengthData c(buf, sizeof(_value));
+ return c;
+}
+
+/* Alternate encode for directly filling a buffer */
+unsigned long HandleImplementation::encodedLength() const
+{
+ return sizeof(_value);
+}
+unsigned long HandleImplementation::encode(
+ void* buffer, unsigned long bufferSize) const
+throw (CouldNotEncode)
+{
+ if (bufferSize < sizeof(_value))
+ throw CouldNotEncode(L"Not enough room in buffer to encode handle");
+
+ unsigned long val = _value;
+ char *buf = (char *) buffer;
+ for(uint32_t i = 0; i < sizeof(_value); i++)
+ {
+ buf[sizeof(_value)-i-1] = (char) val & 0xFF;
+ val = val >> 8;
+ }
+ return sizeof(_value);
+}
+
+std::wstring HandleImplementation::toString() const
+{
+ std::wostringstream ost;
+ ost << _value;
+ return ost.str();
+}
+
+
+
+#define DECLARE_HANDLE_IMPLEMENTATION_CLASS(HIK) \
+ \
+ /* Constructs an invalid handle */ \
+ HIK::HIK() \
+ : HandleImplementation() \
+ { \
+ } \
+ \
+ HIK::HIK(VariableLengthData const & encodedValue) \
+ : HandleImplementation(encodedValue) \
+ { \
+ \
+ } \
+ \
+ HIK::~HIK() \
+ throw() \
+ { \
+ } \
+ \
+ HIK::HIK(HIK const & rhs) \
+ { \
+ _value = rhs._value;
\
+ } \
+ \
+ HIK & HIK::operator=(HIK const & rhs) \
+ { \
+ if (this != &rhs) \
+ { \
+ _value = rhs._value; \
+ } \
+ return *this; \
+ } \
+ \
+ \
+ /* All invalid handles are equivalent */ \
+ bool HIK::operator==(HIK const & rhs) const \
+ { \
+ return _value == rhs._value; \
+ } \
+ bool HIK::operator!=(HIK const & rhs) const \
+ { \
+ return _value != rhs._value; \
+ } \
+ bool HIK::operator< (HIK const & rhs) const \
+ { \
+ return _value < rhs._value; \
+ } \
+ \
+ /* end DECLARE_HANDLE_IMPLEMENTATION_CLASS */
+
+
+DECLARE_HANDLE_IMPLEMENTATION_CLASS(FederateHandleImplementation)
+DECLARE_HANDLE_IMPLEMENTATION_CLASS(ObjectClassHandleImplementation)
+DECLARE_HANDLE_IMPLEMENTATION_CLASS(InteractionClassHandleImplementation)
+DECLARE_HANDLE_IMPLEMENTATION_CLASS(ObjectInstanceHandleImplementation)
+DECLARE_HANDLE_IMPLEMENTATION_CLASS(AttributeHandleImplementation)
+DECLARE_HANDLE_IMPLEMENTATION_CLASS(ParameterHandleImplementation)
+DECLARE_HANDLE_IMPLEMENTATION_CLASS(DimensionHandleImplementation)
+//DECLARE_HANDLE_IMPLEMENTATION_CLASS(MessageRetractionHandleImplementation)
+DECLARE_HANDLE_IMPLEMENTATION_CLASS(RegionHandleImplementation)
+
+
+MessageRetractionHandleImplementation::MessageRetractionHandleImplementation()
+: HandleImplementation()
+{
+}
+
+MessageRetractionHandleImplementation::MessageRetractionHandleImplementation(MessageRetractionHandleImplementation
const & rhs)
+{
+ _value = rhs._value;
+}
+
+MessageRetractionHandleImplementation::MessageRetractionHandleImplementation(VariableLengthData
const & encodedValue)
+{
+ ULong val1 = 0;
+ ULong val2 = 0;
+ const size_t size = sizeof(val1);
+ unsigned char buf1[size];
+ unsigned char buf2[size];
+
+ if (encodedValue.size() != 2*size) {
+ throw CouldNotDecode(L"Encoded value has an unexpected size.");
+ }
+
+ memcpy(&val1, encodedValue.data(), size);
+ memcpy(&val2, (ULong*)encodedValue.data() + 1 , size);
+
+ // _value
+ for(uint32_t i = 0; i < sizeof(val1); i++)
+ {
+ buf1[size-i-1] = (char) val1 & 0xFF;
+ val1 = val1 >> 8;
+ }
+ //copy buf1 to _value
+ ULong newValue;
+ memcpy(&newValue, buf1, size);
+ _value = newValue;
+
+ // _serialNum
+ for(uint32_t i = 0; i < sizeof(val2); i++)
+ {
+ buf2[size-i-1] = (char) val2 & 0xFF;
+ val2 = val2 >> 8;
+ }
+ //copy buf2 to _serailNum
+ ULong newSerialNum;
+ memcpy(&newSerialNum, buf2, size);
+ _serialNum = newSerialNum;
+}
+
+MessageRetractionHandleImplementation::~MessageRetractionHandleImplementation()
+throw()
+{
+}
+
+MessageRetractionHandleImplementation &
MessageRetractionHandleImplementation::operator=(MessageRetractionHandleImplementation
const & rhs)
+{
+ if (this != &rhs) {
+ _value = rhs._value;
+ }
+ return *this;
+}
+
+bool
MessageRetractionHandleImplementation::operator==(MessageRetractionHandleImplementation
const & rhs) const
+ {
+ bool isEqual = (_value == rhs._value) && (_serialNum == rhs._serialNum);
+ return isEqual;
+ }
+
+bool
MessageRetractionHandleImplementation::operator!=(MessageRetractionHandleImplementation
const & rhs) const
+ {
+ bool isEqual = (_value == rhs._value) && (_serialNum == rhs._serialNum);
+ return !isEqual;
+ }
+
+bool MessageRetractionHandleImplementation::operator<
(MessageRetractionHandleImplementation const & rhs) const
+{
+ return _value < rhs._value;
+}
+
+/* Generate an encoded value that can be used to send */
+/* handles to other federates in updates or interactions. */
+VariableLengthData MessageRetractionHandleImplementation::encode() const
+{
+ unsigned char buf[ sizeof(_value) + sizeof(_serialNum) ];
+ encode(buf, sizeof(_value) + sizeof(_serialNum) );
+ VariableLengthData c(buf, sizeof(_value) + sizeof(_serialNum) );
+ return c;
+}
+
+/* Alternate encode for directly filling a buffer */
+unsigned long MessageRetractionHandleImplementation::encodedLength() const
+{
+ return sizeof(_value) + sizeof(_serialNum);
+}
+
+unsigned long MessageRetractionHandleImplementation::encode(
+ void* buffer, unsigned long bufferSize) const
+throw (CouldNotEncode)
+{
+ if ( bufferSize < (sizeof(_value)+sizeof(_serialNum)) )
+ throw CouldNotEncode(L"Not enough room in buffer to encode handle");
+
+ unsigned long val = _value;
+ unsigned long serialNum = _serialNum;
+ char *buf = (char *) buffer;
+ for(uint32_t i = 0; i < sizeof(_value); i++)
+ {
+ buf[sizeof(_value)-i-1] = (char) val & 0xFF;
+ val = val >> 8;
+ }
+ for(uint32_t i = 0; i < sizeof(_serialNum); i++)
+ {
+ buf[sizeof(_value)+sizeof(_serialNum)-i-1] = (char) serialNum & 0xFF;
+ serialNum = serialNum >> 8;
+ }
+ return sizeof(_value) + sizeof(_serialNum);
+}
+
+
+} // end namespace rti1516
Index: include/ieee1516-2010/RTI/certiLogicalTimeInterval.h
===================================================================
RCS file: include/ieee1516-2010/RTI/certiLogicalTimeInterval.h
diff -N include/ieee1516-2010/RTI/certiLogicalTimeInterval.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ include/ieee1516-2010/RTI/certiLogicalTimeInterval.h 3 Mar 2014
16:43:28 -0000 1.1
@@ -0,0 +1,146 @@
+/***********************************************************************
+ IEEE 1516.1 High Level Architecture Interface Specification C++ API
+ File: RTI/LogicalTimeInterval.h
+***********************************************************************/
+
+#ifndef RTI_LogicalTimeInterval_h
+#define RTI_LogicalTimeInterval_h
+
+// ****************************************************************
+// ********************** Adjusted for CERTI **********************
+// ****************************************************************
+// This file is one of the SISO HLA 1516 header files that was edited
+// by CERTI for compilation. By default, there exists a circular
+// dependency between the RTI library (provided by CERTI) and the
+// LogicalTime implementation (to be provided by the federate).
+// In order to break this dependency some minor changes have been
+// applied: The LogicalTime, LogicalTimeInterval and
+// LogicalTimeFactory classes are now exported by the LogicalTime
+// implementation. All three classes have been given an inline (empty)
+// destructor.
+// While these changes may break (direct) DLL compatibility, they
+// greatly ease the implementation of the RTI1516 library for CERTI.
+// ****************************************************************
+// ********************** Adjusted for CERTI **********************
+// ****************************************************************
+
+
+// The classes associated with logical time allow a federation to provide
+// their own representation for logical time and logical time interval. The
+// federation is responsible to inherit from the abstract classes declared
+// below. The encoded time classes are used to hold the arbitrary bit
+// representation of the logical time and logical time intervals.
+
+namespace rti1516
+{
+ class LogicalTime;
+}
+
+#include <RTI/SpecificConfig.h>
+#include <RTI/Exception.h>
+#include <string>
+#include <RTI/VariableLengthData.h>
+
+namespace rti1516
+{
+ class FEDTIME_EXPORT LogicalTimeInterval
+ {
+ public:
+ virtual
+ ~LogicalTimeInterval()
+ throw () { };
+
+ virtual
+ void
+ setZero() = 0;
+
+ virtual
+ bool
+ isZero() const = 0;
+
+ virtual
+ void
+ setEpsilon() = 0;
+
+ virtual
+ bool
+ isEpsilon() const = 0;
+
+ virtual
+ LogicalTimeInterval &
+ operator=(LogicalTimeInterval const & value)
+ throw (InvalidLogicalTimeInterval) = 0;
+
+ // Set self to the difference between two LogicalTimes
+ virtual
+ void
+ setToDifference(LogicalTime const & minuend,
+ LogicalTime const& subtrahend)
+ throw (InvalidLogicalTime) = 0;
+
+ virtual
+ LogicalTimeInterval &
+ operator+=(LogicalTimeInterval const & addend)
+ throw (InvalidLogicalTimeInterval) = 0;
+
+ virtual
+ LogicalTimeInterval &
+ operator-=(LogicalTimeInterval const & subtrahend)
+ throw (InvalidLogicalTimeInterval) = 0;
+
+ virtual
+ bool
+ operator>(LogicalTimeInterval const & value) const
+ throw (InvalidLogicalTimeInterval) = 0;
+
+ virtual
+ bool
+ operator<(LogicalTimeInterval const & value) const
+ throw (InvalidLogicalTimeInterval) = 0;
+
+ virtual
+ bool
+ operator==(LogicalTimeInterval const & value) const
+ throw (InvalidLogicalTimeInterval) = 0;
+
+ virtual
+ bool
+ operator>=(LogicalTimeInterval const & value) const
+ throw (InvalidLogicalTimeInterval) = 0;
+
+ virtual
+ bool
+ operator<=(LogicalTimeInterval const & value) const
+ throw (InvalidLogicalTimeInterval) = 0;
+
+ // Generates an encoded value that can be used to send
+ // LogicalTimeIntervals to other federates in updates or interactions
+ virtual VariableLengthData encode() const = 0;
+
+ // Alternate encode for directly filling a buffer
+ virtual unsigned long encodedLength() const = 0;
+ virtual unsigned long encode(void* buffer, unsigned long bufferSize) const
+ throw (CouldNotEncode) = 0;
+
+ // Decode encodedValue into self
+ virtual void decode(VariableLengthData const & encodedValue)
+ throw (InternalError,
+ CouldNotDecode) = 0;
+
+ // Alternate decode that reads directly from a buffer
+ virtual void decode(void* buffer, unsigned long bufferSize)
+ throw (InternalError,
+ CouldNotDecode) = 0;
+
+ virtual std::wstring toString() const = 0;
+
+ // Returns the name of the implementation, as needed by
+ // createFederationExecution.
+ virtual std::wstring implementationName() const = 0;
+ };
+
+ // Output operator for LogicalTimeInterval
+ std::wostream RTI_EXPORT &
+ operator << (std::wostream &, LogicalTimeInterval const &);
+}
+#endif // RTI_LogicalTimeInterval_h
Index: include/ieee1516-2010/RTI/certiRTI1516.h
===================================================================
RCS file: include/ieee1516-2010/RTI/certiRTI1516.h
diff -N include/ieee1516-2010/RTI/certiRTI1516.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ include/ieee1516-2010/RTI/certiRTI1516.h 3 Mar 2014 16:43:29 -0000
1.1
@@ -0,0 +1,73 @@
+/***********************************************************************
+ IEEE 1516.1 High Level Architecture Interface Specification C++ API
+ File: RTI/1516.h
+***********************************************************************/
+
+// ****************************************************************
+// ********************** Adjusted for CERTI **********************
+// ****************************************************************
+// This file is one of the SISO HLA 1516 header files that was edited
+// by CERTI for compilation. By default, there exists a circular
+// dependency between the RTI library (provided by CERTI) and the
+// LogicalTime implementation (to be provided by the federate).
+// In order to break this dependency some minor changes have been
+// applied: The LogicalTime, LogicalTimeInterval and
+// LogicalTimeFactory classes are now exported by the LogicalTime
+// implementation. All three classes have been given an inline (empty)
+// destructor.
+// While these changes may break (direct) DLL compatibility, they
+// greatly ease the implementation of the RTI1516 library for CERTI.
+// ****************************************************************
+// ********************** Adjusted for CERTI **********************
+// ****************************************************************
+
+
+//
+// This file is simply a convenience provided for those developers that would
+// like to include everything all at once
+//
+
+#ifndef RTI_1516_h
+#define RTI_1516_h
+
+// Identification of the API version number.
+#define HLA_SPECIFICATION_NAME "1516"
+#define HLA_API_MAJOR_VERSION 2
+#define HLA_API_MINOR_VERSION 0
+
+// This file contains platform specific configuration info.
+#include <RTI/SpecificConfig.h>
+
+// These file include declarations/definitions for ISO 14882 standard C++
+// classes, renamed for portability.
+#include <string>
+#include <set>
+#include <map>
+#include <vector>
+#include <memory>
+
+// This file contains standard RTI type declarations/definitions.
+#include <RTI/Exception.h>
+#include <RTI/Handle.h>
+#include <RTI/Enums.h>
+#include <RTI/RangeBounds.h>
+
+// This file contains standard RTI type declarations/definitions which depend
on
+// RTI implementation specific declarations/definitions.
+#include <RTI/Typedefs.h>
+#include <RTI/certiLogicalTime.h>
+#include <RTI/certiLogicalTimeFactory.h>
+#include <RTI/certiLogicalTimeInterval.h>
+
+namespace rti1516
+{
+ // Vendor-specific name and version of the RTI implementation
+ std::wstring RTI_EXPORT RTIname();
+ std::wstring RTI_EXPORT RTIversion();
+}
+
+#include <RTI/FederateAmbassador.h>
+#include <RTI/RTIambassador.h>
+#include <RTI/RTIambassadorFactory.h>
+
+#endif // RTI_1516_h
Index: include/ieee1516-2010/RTI/certiLogicalTime.h
===================================================================
RCS file: include/ieee1516-2010/RTI/certiLogicalTime.h
diff -N include/ieee1516-2010/RTI/certiLogicalTime.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ include/ieee1516-2010/RTI/certiLogicalTime.h 3 Mar 2014 16:43:29
-0000 1.1
@@ -0,0 +1,141 @@
+/***********************************************************************
+ IEEE 1516.1 High Level Architecture Interface Specification C++ API
+ File: RTI/LogicalTime.h
+***********************************************************************/
+
+#ifndef RTI_LogicalTime_h
+#define RTI_LogicalTime_h
+
+// ****************************************************************
+// ********************** Adjusted for CERTI **********************
+// ****************************************************************
+// This file is one of the SISO HLA 1516 header files that was edited
+// by CERTI for compilation. By default, there exists a circular
+// dependency between the RTI library (provided by CERTI) and the
+// LogicalTime implementation (to be provided by the federate).
+// In order to break this dependency some minor changes have been
+// applied: The LogicalTime, LogicalTimeInterval and
+// LogicalTimeFactory classes are now exported by the LogicalTime
+// implementation. All three classes have been given an inline (empty)
+// destructor.
+// While these changes may break (direct) DLL compatibility, they
+// greatly ease the implementation of the RTI1516 library for CERTI.
+// ****************************************************************
+// ********************** Adjusted for CERTI **********************
+// ****************************************************************
+
+
+
+// The classes associated with logical time allow a federation to provide their
+// own representation for logical time and logical time interval. The
federation
+// is responsible to inherit from the abstract classes declared below. The
+// encoded time classes are used to hold the arbitrary bit representation of
the
+// logical time and logical time intervals.
+
+namespace rti1516
+{
+ class LogicalTimeInterval;
+}
+
+#include <RTI/SpecificConfig.h>
+#include <RTI/Exception.h>
+#include <string>
+#include <RTI/VariableLengthData.h>
+
+namespace rti1516
+{
+ class FEDTIME_EXPORT LogicalTime
+ {
+ public:
+ virtual
+ ~LogicalTime()
+ throw () { };
+
+ virtual
+ void
+ setInitial() = 0;
+
+ virtual
+ bool
+ isInitial() const = 0;
+
+ virtual
+ void
+ setFinal() = 0;
+
+ virtual
+ bool
+ isFinal() const = 0;
+
+ virtual
+ LogicalTime &
+ operator=(LogicalTime const & value)
+ throw (InvalidLogicalTime) = 0;
+
+ virtual
+ LogicalTime &
+ operator+=(LogicalTimeInterval const & addend)
+ throw (IllegalTimeArithmetic, InvalidLogicalTimeInterval) = 0;
+
+ virtual
+ LogicalTime &
+ operator-=(LogicalTimeInterval const & subtrahend)
+ throw (IllegalTimeArithmetic, InvalidLogicalTimeInterval) = 0;
+
+ virtual
+ bool
+ operator>(LogicalTime const & value) const
+ throw (InvalidLogicalTime) = 0;
+
+ virtual
+ bool
+ operator<(LogicalTime const & value) const
+ throw (InvalidLogicalTime) = 0;
+
+ virtual
+ bool
+ operator==(LogicalTime const & value) const
+ throw (InvalidLogicalTime) = 0;
+
+ virtual
+ bool
+ operator>=(LogicalTime const & value) const
+ throw (InvalidLogicalTime) = 0;
+
+ virtual
+ bool
+ operator<=(LogicalTime const & value) const
+ throw (InvalidLogicalTime) = 0;
+
+ // Generates an encoded value that can be used to send
+ // LogicalTimes to other federates in updates or interactions
+ virtual VariableLengthData encode() const = 0;
+
+ // Alternate encode for directly filling a buffer
+ virtual unsigned long encodedLength() const = 0;
+ virtual unsigned long encode(void* buffer, unsigned long bufferSize) const
+ throw (CouldNotEncode) = 0;
+
+ // Decode encodedLogicalTime into self
+ virtual void decode(VariableLengthData const & encodedLogicalTime)
+ throw (InternalError,
+ CouldNotDecode) = 0;
+
+ // Alternate decode that reads directly from a buffer
+ virtual void decode(void* buffer, unsigned long bufferSize)
+ throw (InternalError,
+ CouldNotDecode) = 0;
+
+ virtual std::wstring toString() const = 0;
+
+ // Returns the name of the implementation, as needed by
+ // createFederationExecution.
+ virtual std::wstring implementationName() const = 0;
+ };
+
+ // Output operator for LogicalTime
+ std::wostream RTI_EXPORT &
+ operator << (std::wostream &, LogicalTime const &);
+}
+
+#endif // RTI_LogicalTime_h
Index: include/ieee1516-2010/RTI/certiLogicalTimeFactory.h
===================================================================
RCS file: include/ieee1516-2010/RTI/certiLogicalTimeFactory.h
diff -N include/ieee1516-2010/RTI/certiLogicalTimeFactory.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ include/ieee1516-2010/RTI/certiLogicalTimeFactory.h 3 Mar 2014 16:43:29
-0000 1.1
@@ -0,0 +1,95 @@
+/***********************************************************************
+ IEEE 1516.1 High Level Architecture Interface Specification C++ API
+ File: RTI/LogicalTimeFactory.h
+***********************************************************************/
+
+#ifndef RTI_LogicalTimeFactory_h
+#define RTI_LogicalTimeFactory_h
+
+// ****************************************************************
+// ********************** Adjusted for CERTI **********************
+// ****************************************************************
+// This file is one of the SISO HLA 1516 header files that was edited
+// by CERTI for compilation. By default, there exists a circular
+// dependency between the RTI library (provided by CERTI) and the
+// LogicalTime implementation (to be provided by the federate).
+// In order to break this dependency some minor changes have been
+// applied: The LogicalTime, LogicalTimeInterval and
+// LogicalTimeFactory classes are now exported by the LogicalTime
+// implementation. All three classes have been given an inline (empty)
+// destructor.
+// While these changes may break (direct) DLL compatibility, they
+// greatly ease the implementation of the RTI1516 library for CERTI.
+// ****************************************************************
+// ********************** Adjusted for CERTI **********************
+// ****************************************************************
+
+
+namespace rti1516
+{
+ class LogicalTime;
+ class LogicalTimeInterval;
+}
+
+namespace std
+{
+ template <class T> class auto_ptr;
+}
+
+#include <RTI/SpecificConfig.h>
+#include <RTI/Exception.h>
+#include <string>
+
+// LogicalTimeFactory is used by the RTI to construct instances of classes
+// derived from LogicalTime and LogicalTimeInterval. A federation is
responsible
+// for providing a fedtime library that includes one or more subclasses
+// of LogicalTime and LogicalTimeInterval, one or more subclasses of
LogicalTimeFactory
+// (which is used to create instances of those LogicalTime and
LogicalTimeInterval
+// subclasses), and a single implementation of
+// LogicalTimeFactoryFactory::createLogicalTimeFactory. This static function
should
+// choose a LogicalTimeFactory based on the string identifier passed as an
argument,
+// and return an instance of that kind of factory. The RTI will call this
function to
+// obtain a LogicalTimeFactory for a federation, and then will use that
factory to create
+// any instances of LogicalTime or LogicalTimeInterval that it needs.
+
+namespace rti1516
+{
+ class FEDTIME_EXPORT LogicalTimeFactory
+ {
+ public:
+ virtual
+ ~LogicalTimeFactory()
+ throw () { };
+
+ // Returns a LogicalTime with a value of "initial"
+ virtual
+ std::auto_ptr< LogicalTime >
+ makeLogicalTime()
+ throw (InternalError) = 0;
+
+ // Returns a LogicalTimeInterval with a value of "zero"
+ virtual
+ std::auto_ptr< LogicalTimeInterval >
+ makeLogicalTimeInterval()
+ throw (InternalError) = 0;
+ };
+}
+
+namespace rti1516
+{
+ class FEDTIME_EXPORT LogicalTimeFactoryFactory
+ {
+ public:
+
+ // The name is used to choose among several LogicalTimeFactories that might
+ // be present in the fedtime library. Each federation chooses its
+ // implementation by passing the appropriate name to
createFederationExecution.
+ // If the supplied name is the empty string, a default LogicalTimeFactory
is
+ // returned. If the supplied implementation name does not match any name
+ // supported by the library, then a NULL pointer is returned.
+ static std::auto_ptr< LogicalTimeFactory >
+ makeLogicalTimeFactory(std::wstring const & implementationName);
+ };
+}
+
+#endif // RTI_LogicalTimeFactory_h
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [certi-cvs] certi libRTI/ieee1516-2010/RTIvariableLengthDat...,
CERTI CVS commits <=