1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
15#define OSG_FRAMESTAMP 1
17#include <osg/Referenced>
19#if defined(__sgi) || (defined(WIN32) && !defined(__MWERKS__))
29/** Class which encapsulates the frame number, reference time and calendar
30 * time of specific frame, used to synchronize operations on the scene graph
31 * and other machines when using a graphics cluster. Note the calendar
32 * time can be an artificial simulation time or capture the real time
34class OSG_EXPORT FrameStamp : public Referenced
39 FrameStamp(const FrameStamp& fs);
41 FrameStamp& operator = (const FrameStamp& fs);
43 void setFrameNumber(unsigned int fnum) { _frameNumber = fnum; }
44 unsigned int getFrameNumber() const { return _frameNumber; }
46 void setReferenceTime(double refTime) { _referenceTime = refTime; }
47 double getReferenceTime() const { return _referenceTime; }
49 void setSimulationTime(double refTime) { _simulationTime = refTime; }
50 double getSimulationTime() const { return _simulationTime; }
52 void setCalendarTime(const tm& calendarTime);
53 void getCalendarTime(tm& calendarTime) const;
55 // keep public to allow it to be permit allocation which is
56 // not on the heap used osgcluster
57 virtual ~FrameStamp();
62 // note no dynamic memory is used so that data can be passed
63 // via a simple memory copy or within a data packet across
66 unsigned int _frameNumber;
67 double _referenceTime;
68 double _simulationTime;
70 // member variables of time.h's tm structure, copied here to
71 // ensure that all data is not dynamic. The tm structure itself
72 // is not completely consistent between implementations, which
73 // could be a problem when sending the FrameStamp across a network
74 // with different versions of tm (i.e mixing Unix and Windows.)
75 int tm_sec; /* Seconds. [0-60] (1 leap second) */
76 int tm_min; /* Minutes. [0-59] */
77 int tm_hour; /* Hours. [0-23] */
78 int tm_mday; /* Day. [1-31] */
79 int tm_mon; /* Month. [0-11] */
80 int tm_year; /* Year - 1900. */
81 int tm_wday; /* Day of week. [0-6] */
82 int tm_yday; /* Days in year. [0-365] */
83 int tm_isdst; /* DST. [-1/0/1]*/