Update of /cvsroot/csp/APPLICATIONS/SimData/Include/SimData
In directory sc8-pr-cvs1:/tmp/cvs-serv3500/Include/SimData
Modified Files:
DataArchive.h DataManager.h Date.h InterfaceRegistry.h
ObjectInterface.h Pack.h Pack.i TypeAdapter.h osg.h
Log Message:
see CHANGES
Index: DataArchive.h
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/SimData/Include/SimData/DataArchive.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** DataArchive.h 23 Apr 2003 09:14:20 -0000 1.10
--- DataArchive.h 2 May 2003 20:59:04 -0000 1.11
***************
*** 336,339 ****
--- 336,347 ----
std::vector<std::string> getAllPathStrings() const;
+ /**
+ * Remove unused static objects from the cache.
+ *
+ * Call this method after many objects have been deleted
+ * to free any unused cache entries.
+ */
+ void cleanStatic();
+
// protected methods made public for Python access, don't use!
/*
Index: DataManager.h
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/SimData/Include/SimData/DataManager.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** DataManager.h 23 Apr 2003 09:14:20 -0000 1.3
--- DataManager.h 2 May 2003 20:59:04 -0000 1.4
***************
*** 139,142 ****
--- 139,150 ----
std::string getPathString(ObjectID const &id) const;
+ /**
+ * Remove unused static objects from the cache.
+ *
+ * Call this method after many objects have been deleted
+ * to free any unused cache entries.
+ */
+ void cleanStatic();
+
private:
/**
Index: Date.h
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/SimData/Include/SimData/Date.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Date.h 12 Apr 2003 08:56:37 -0000 1.8
--- Date.h 2 May 2003 20:59:04 -0000 1.9
***************
*** 107,111 ****
#define F1p0_24p0 0.041666666666666667L
#define F1p0_36525p0 0.000027378507871321L
! #define F1p0_86000p0 0.000011627906976744L
--- 107,111 ----
#define F1p0_24p0 0.041666666666666667L
#define F1p0_36525p0 0.000027378507871321L
! #define F1p0_86400p0 0.000011574074074074L
***************
*** 566,579 ****
return ((int)m_time) % 60;
}
/**
! * Advance the time.
*
* @param dt the number of seconds to add.
! * @return true if the time exceeds 24 hours (zulu)
*/
! bool addTime(time_t dt) {
m_time += dt;
! return overflow();
}
--- 566,589 ----
return ((int)m_time) % 60;
}
+
+ int rollover() {
+ int days = 0;
+ if (overflow()) {
+ days = (int) (m_time * 0.00001157407407407407);
+ if (m_time < 0.0) days--;
+ m_time -= days * 86400.0f;
+ }
+ return days;
+ }
/**
! * Advance the time, with 24 hour clock rollover.
*
* @param dt the number of seconds to add.
! * @return the number days added or subtracted
*/
! int addTime(time_t dt) {
m_time += dt;
! return rollover();
}
***************
*** 584,590 ****
* @param local if true, t represents the local time (not zulu).
*/
! void setTime(time_t t, bool local=false) {
if (local) t -= m_tz * 3600.0;
m_time = t;
}
--- 594,601 ----
* @param local if true, t represents the local time (not zulu).
*/
! int setTime(time_t t, bool local=false) {
if (local) t -= m_tz * 3600.0;
m_time = t;
+ return rollover();
}
***************
*** 668,683 ****
* @param dt The time interval (in seconds)
*/
! void addTime(time_t dt) {
! Zulu::addTime(dt);
! addDays(reduce());
}
! void setTime(time_t t) {
! Zulu::setTime(t);
! addDays(reduce());
}
double getJulianDate() const {
double j = getJulian();
! double t = getTime() * F1p0_86000p0 + 0.5;
return j + t;
}
--- 679,702 ----
* @param dt The time interval (in seconds)
*/
! int addTime(time_t dt) {
! int days = Zulu::addTime(dt);
! addDays(days);
! return days;
}
!
! /**
! * Set the current time, with date rollover.
! *
! * @param t The current time of day (in seconds)
! */
! int setTime(time_t t) {
! int days = Zulu::setTime(t);
! addDays(days);
! return days;
}
double getJulianDate() const {
double j = getJulian();
! double t = getTime() * F1p0_86400p0 + 0.5;
return j + t;
}
***************
*** 747,751 ****
/* The difference between two times. Both times
! * should be in the range [0, 86000).
*
* @param a A time value.
--- 766,770 ----
/* The difference between two times. Both times
! * should be in the range [0, 86400).
*
* @param a A time value.
***************
*** 754,758 ****
static SimTime interval(SimTime a, SimTime b) {
a -= b;
! if (a < 0.0) return a + 86000.0;
return a;
}
--- 773,777 ----
static SimTime interval(SimTime a, SimTime b) {
a -= b;
! if (a < 0.0) return a + 86400.0;
return a;
}
***************
*** 781,785 ****
* Set the time reference to produce the desired target time
*
! * @param target The desired simulation time, right NOW! (seconds: 0-86000)
*/
void setReferenceTime(SimTime target) {
--- 800,804 ----
* Set the time reference to produce the desired target time
*
! * @param target The desired simulation time, right NOW! (seconds: 0-86400)
*/
void setReferenceTime(SimTime target) {
***************
*** 806,809 ****
--- 825,854 ----
bool isPaused() {
return paused;
+ }
+
+ /**
+ * Increment the current time, with date rollover and reference fixup.
+ *
+ * @param dt The time interval (in seconds)
+ */
+ int addTime(time_t dt) {
+ int days = DateZulu::addTime(dt);
+ if (days != 0) {
+ reference += days * 86400.0;
+ }
+ return days;
+ }
+
+ /**
+ * Set the current time, with date rollover and reference fixup.
+ *
+ * @param t The current time of day (in seconds)
+ */
+ int setTime(time_t t) {
+ int days = DateZulu::setTime(t);
+ if (days != 0) {
+ reference += days * 86400.0;
+ }
+ return days;
}
Index: InterfaceRegistry.h
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/SimData/Include/SimData/InterfaceRegistry.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** InterfaceRegistry.h 23 Apr 2003 09:14:20 -0000 1.14
--- InterfaceRegistry.h 2 May 2003 20:59:04 -0000 1.15
***************
*** 360,363 ****
--- 360,371 ----
#ifdef SWIG
+ #define SIMDATA_BIT(id, var, bit, req)
+ #else
+ #define SIMDATA_BIT(id, var, bit, req) .def(id, &var, bit, req)
+ #endif
+
+ //-----------------------------------------
+
+ #ifdef SWIG
#define END_SIMDATA_XML_INTERFACE
#else
Index: ObjectInterface.h
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/SimData/Include/SimData/ObjectInterface.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** ObjectInterface.h 23 Apr 2003 09:14:21 -0000 1.14
--- ObjectInterface.h 2 May 2003 20:59:04 -0000 1.15
***************
*** 110,113 ****
--- 110,160 ----
+ template <class C, typename T>
+ class MemberMaskAccessor: public MemberAccessorBase
+ {
+ T C::* member;
+ T mask;
+ public:
+ MemberMaskAccessor(T C::*pm, std::string name_, int mask_, bool required_) {
+ member = pm;
+ name = name_;
+ mask = mask_;
+ required = required_;
+ }
+ virtual TypeAdapter const get(Object *o) const throw(TypeMismatch) {
+ C * object = dynamic_cast<C *>(o);
+ if (object == NULL) {
+ throw TypeMismatch("get(\"" + name + "\"): Object class does not match interface.");
+ }
+ return TypeAdapter(object->*member);
+ }
+ virtual void set(Object *o, TypeAdapter const &v) throw(TypeMismatch) {
+ C * object = dynamic_cast<C *>(o);
+ if (object == NULL) {
+ throw TypeMismatch("set(\"" + name + "\"): Object class does not match interface.");
+ }
+ if (mask != 0) {
+ T value;
+ v.set(value);
+ if (value != 0) {
+ object->*member |= mask;
+ } else {
+ object->*member &= ~mask;
+ }
+ } else {
+ v.set(object->*member);
+ }
+ }
+ virtual void pack(Object *o, Packer &p) const {
+ C * object = dynamic_cast<C *>(o);
+ p.pack(object->*member);
+ }
+ virtual void unpack(Object *o, UnPacker &p) {
+ C * object = dynamic_cast<C *>(o);
+ p.unpack(object->*member);
+ }
+ };
+
+
/**
* class MemberAccessor - Class for storing and accessing member variable
***************
*** 258,261 ****
--- 305,389 ----
}
};
+
+ template <class C>
+ class MemberAccessor< C, int >: public MemberMaskAccessor<C, int> {
+ public:
+ MemberAccessor(int C::*pm, std::string name_, bool required_):
+ MemberMaskAccessor<C, int>(pm, name_, 0, required_) { }
+ MemberAccessor(int C::*pm, std::string name_, int mask_, bool required_):
+ MemberMaskAccessor<C, int>(pm, name_, mask_, required_) { }
+ };
+
+ template <class C>
+ class MemberAccessor< C, short >: public MemberMaskAccessor<C, short> {
+ public:
+ MemberAccessor(short C::*pm, std::string name_, bool required_):
+ MemberMaskAccessor<C, short>(pm, name_, 0, required_) { }
+ MemberAccessor(short C::*pm, std::string name_, int mask_, bool required_):
+ MemberMaskAccessor<C, short>(pm, name_, mask_, required_) { }
+ };
+
+ template <class C>
+ class MemberAccessor< C, char >: public MemberMaskAccessor<C, char> {
+ public:
+ MemberAccessor(char C::*pm, std::string name_, bool required_):
+ MemberMaskAccessor<C, char>(pm, name_, 0, required_) { }
+ MemberAccessor(char C::*pm, std::string name_, int mask_, bool required_):
+ MemberMaskAccessor<C, char>(pm, name_, mask_, required_) { }
+ };
+
+ /*
+ template <class C>
+ class MemberAccessor< C, int >: public MemberAccessorBase
+ {
+ int C::* member;
+ int mask;
+ public:
+ MemberAccessor(int C::*pm, std::string name_, bool required_) {
+ member = pm;
+ name = name_;
+ mask = 0;
+ required = required_;
+ }
+ MemberAccessor(int C::*pm, std::string name_, int mask_, bool required_) {
+ member = pm;
+ name = name_;
+ mask = mask_;
+ required = required_;
+ }
+ virtual TypeAdapter const get(Object *o) const throw(TypeMismatch) {
+ C * object = dynamic_cast<C *>(o);
+ if (object == NULL) {
+ throw TypeMismatch("get(\"" + name + "\"): Object class does not match interface.");
+ }
+ return TypeAdapter(object->*member);
+ }
+ virtual void set(Object *o, TypeAdapter const &v) throw(TypeMismatch) {
+ C * object = dynamic_cast<C *>(o);
+ if (object == NULL) {
+ throw TypeMismatch("set(\"" + name + "\"): Object class does not match interface.");
+ }
+ if (mask != 0) {
+ int value;
+ v.set(value);
+ if (value != 0) {
+ object->*member |= mask;
+ } else {
+ object->*member &= ~mask;
+ }
+ } else {
+ v.set(object->*member);
+ }
+ }
+ virtual void pack(Object *o, Packer &p) const {
+ C * object = dynamic_cast<C *>(o);
+ p.pack(object->*member);
+ }
+ virtual void unpack(Object *o, UnPacker &p) {
+ C * object = dynamic_cast<C *>(o);
+ p.unpack(object->*member);
+ }
+ };
+ */
#endif
***************
*** 386,389 ****
--- 514,527 ----
#else
table[name] = new MemberAccessor<C, T>(pm, name, required);
+ #endif
+ return *this;
+ }
+ template<typename T>
+ Self& def(const char *name, T C::*pm, int mask, bool required) throw(InterfaceError) {
+ if (variableExists(name)) throw InterfaceError("interface variable \"" + std::string(name) + "\" multiply defined.");
+ #ifdef __PTS_SIM__
+ table[name] = new typename PTS::SELECT_ACCESSOR<C, T>::ACCESSOR(pm, name, required);
+ #else
+ table[name] = new MemberAccessor<C, T>(pm, name, mask, required);
#endif
return *this;
Index: Pack.h
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/SimData/Include/SimData/Pack.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Pack.h 23 Apr 2003 09:14:21 -0000 1.5
--- Pack.h 2 May 2003 20:59:04 -0000 1.6
***************
*** 46,54 ****
class DataArchive;
! /**
! * Base class for objects that support serialization to data archives.
! *
! * @author Mark Rose <mr...@st...>
! */
--- 46,51 ----
class DataArchive;
!
! SIMDATA_EXCEPTION(DataUnderflow);
***************
*** 79,82 ****
--- 76,87 ----
// overloaded packing
+ void pack(char x) {
+ write(&x, sizeof(char));
+ _n += sizeof(char);
+ }
+ void pack(short x) {
+ write(&x, sizeof(short));
+ _n += sizeof(short);
+ }
void pack(int x) {
write(&x, sizeof(int));
***************
*** 176,180 ****
void unpack(double& y) {
_n -= sizeof(double);
! assert(_n >= 0);
memcpy(&y, _d, sizeof(double));
_d += sizeof(double);
--- 181,185 ----
void unpack(double& y) {
_n -= sizeof(double);
! if (_n < 0) throw DataUnderflow();
memcpy(&y, _d, sizeof(double));
_d += sizeof(double);
***************
*** 182,186 ****
void unpack(float& y) {
_n -= sizeof(float);
! assert(_n >= 0);
memcpy(&y, _d, sizeof(float));
_d += sizeof(float);
--- 187,191 ----
void unpack(float& y) {
_n -= sizeof(float);
! if (_n < 0) throw DataUnderflow();
memcpy(&y, _d, sizeof(float));
_d += sizeof(float);
***************
*** 188,192 ****
void unpack(int& y) {
_n -= sizeof(int);
! assert(_n >= 0);
memcpy(&y, _d, sizeof(int));
_d += sizeof(int);
--- 193,197 ----
void unpack(int& y) {
_n -= sizeof(int);
! if (_n < 0) throw DataUnderflow();
memcpy(&y, _d, sizeof(int));
_d += sizeof(int);
***************
*** 197,203 ****
y = (x != 0);
}
void unpack(hasht& y) {
_n -= sizeof(hasht);
! assert(_n >= 0);
memcpy(&y, _d, sizeof(hasht));
_d += sizeof(hasht);
--- 202,220 ----
y = (x != 0);
}
+ void unpack(short& y) {
+ _n -= sizeof(short);
+ if (_n < 0) throw DataUnderflow();
+ memcpy(&y, _d, sizeof(short));
+ _d += sizeof(short);
+ }
+ void unpack(char& y) {
+ _n -= sizeof(char);
+ if (_n < 0) throw DataUnderflow();
+ memcpy(&y, _d, sizeof(char));
+ _d += sizeof(char);
+ }
void unpack(hasht& y) {
_n -= sizeof(hasht);
! if (_n < 0) throw DataUnderflow();
memcpy(&y, _d, sizeof(hasht));
_d += sizeof(hasht);
***************
*** 208,212 ****
y = (char*) malloc(sizeof(char)*(n+1));
_n -= n;
! assert(_n >= 0);
memcpy(y, _d, sizeof(char)*n);
y[n] = 0;
--- 225,229 ----
y = (char*) malloc(sizeof(char)*(n+1));
_n -= n;
! if (_n < 0) throw DataUnderflow();
memcpy(y, _d, sizeof(char)*n);
y[n] = 0;
Index: Pack.i
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/SimData/Include/SimData/Pack.i,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Pack.i 28 Jan 2003 23:26:06 -0000 1.2
--- Pack.i 2 May 2003 20:59:04 -0000 1.3
***************
*** 9,12 ****
--- 9,14 ----
%rename(unpack_packable) SIMDATA(UnPacker)::unpack(BaseType&);
+ %ignore SIMDATA(Packer)::pack(char);
+ %ignore SIMDATA(Packer)::pack(short);
%ignore SIMDATA(Packer)::pack(hasht);
%ignore SIMDATA(Packer)::pack(std::string&);
***************
*** 14,17 ****
--- 16,21 ----
%ignore SIMDATA(Packer)::pack(const std::string&);
+ %ignore SIMDATA(UnPacker)::unpack(char &);
+ %ignore SIMDATA(UnPacker)::unpack(short &);
%ignore SIMDATA(UnPacker)::unpack(hasht &);
%ignore SIMDATA(UnPacker)::unpack(std::string&);
Index: TypeAdapter.h
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/SimData/Include/SimData/TypeAdapter.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** TypeAdapter.h 23 Apr 2003 09:14:21 -0000 1.11
--- TypeAdapter.h 2 May 2003 20:59:04 -0000 1.12
***************
*** 161,164 ****
--- 161,167 ----
// list
+ void set(short &x) const { IntCheck(); x = static_cast<short>(var.i); }
+ void set(char &x) const { IntCheck(); x = static_cast<char>(var.i); }
+
void set(int &x) const { IntCheck(); x = static_cast<int>(var.i); }
void set(bool &x) const { IntCheck(); x = (var.i != 0); }
Index: osg.h
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/SimData/Include/SimData/osg.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** osg.h 23 Apr 2003 09:14:21 -0000 1.1
--- osg.h 2 May 2003 20:59:04 -0000 1.2
***************
*** 35,54 ****
#include <SimData/Quaternion.h>
! #include <osg::Vec3>
! #include <osg::Matrix>
! #include <osg::Quat>
NAMESPACE_SIMDATA
! osg::Vec3 toOSG(Vector3 const &v) {
return osg::Vec3(v.x, v.y, v.z);
}
! Vector3 fromOSG(osg::Vec3 const &v) {
! return Vector3(v.x, v.y, v.z);
}
! osg::Matrix toOSG(Matrix3 const &m) {
return osg::Matrix(m[0][0], m[0][1], m[0][2], 0.0,
m[1][0], m[1][1], m[1][2], 0.0,
--- 35,54 ----
#include <SimData/Quaternion.h>
! #include <osg/Vec3>
! #include <osg/Matrix>
! #include <osg/Quat>
NAMESPACE_SIMDATA
! inline osg::Vec3 toOSG(Vector3 const &v) {
return osg::Vec3(v.x, v.y, v.z);
}
! inline Vector3 fromOSG(osg::Vec3 const &v) {
! return Vector3(v.x(), v.y(), v.z());
}
! inline osg::Matrix toOSG(Matrix3 const &m) {
return osg::Matrix(m[0][0], m[0][1], m[0][2], 0.0,
m[1][0], m[1][1], m[1][2], 0.0,
***************
*** 57,72 ****
}
! Matrix3 fromOSG(osg::Matrix const &m) {
! return osg::Matrix(m(0, 0), m(0, 1), m(0, 2),
! m(1, 0), m(1, 1), m(1, 2),
! m(2, 0), m(2, 1), m(2, 2));
}
! osg::Quat toOSG(Quaternion const &q) {
return osg::Quat(q.w, q.x, q.y, q.z);
}
! Quaternion fromOSG(osg::Quat const &q) {
! return Quaterion(q.w(), q.x(), q.y(), q.z());
}
--- 57,72 ----
}
! inline Matrix3 fromOSG(osg::Matrix const &m) {
! return Matrix3(m(0, 0), m(0, 1), m(0, 2),
! m(1, 0), m(1, 1), m(1, 2),
! m(2, 0), m(2, 1), m(2, 2));
}
! inline osg::Quat toOSG(Quaternion const &q) {
return osg::Quat(q.w, q.x, q.y, q.z);
}
! inline Quaternion fromOSG(osg::Quat const &q) {
! return Quaternion(q.w(), q.x(), q.y(), q.z());
}
|