| 1 | /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield |
|---|
| 2 | * |
|---|
| 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. |
|---|
| 7 | * |
|---|
| 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. |
|---|
| 12 | */ |
|---|
| 13 | |
|---|
| 14 | #ifndef OSG_FRAMESTAMP |
|---|
| 15 | #define OSG_FRAMESTAMP 1 |
|---|
| 16 | |
|---|
| 17 | #include <osg/Referenced> |
|---|
| 18 | |
|---|
| 19 | #if defined(__sgi) || (defined(WIN32) && !defined(__MWERKS__)) |
|---|
| 20 | #include <time.h> |
|---|
| 21 | #else |
|---|
| 22 | #include <ctime> |
|---|
| 23 | using std::tm; |
|---|
| 24 | #endif |
|---|
| 25 | |
|---|
| 26 | namespace osg |
|---|
| 27 | { |
|---|
| 28 | |
|---|
| 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 |
|---|
| 33 | * of day etc.*/ |
|---|
| 34 | class OSG_EXPORT FrameStamp : public Referenced |
|---|
| 35 | { |
|---|
| 36 | public: |
|---|
| 37 | |
|---|
| 38 | FrameStamp(); |
|---|
| 39 | FrameStamp(const FrameStamp& fs); |
|---|
| 40 | |
|---|
| 41 | FrameStamp& operator = (const FrameStamp& fs); |
|---|
| 42 | |
|---|
| 43 | void setFrameNumber(unsigned int fnum) { _frameNumber = fnum; } |
|---|
| 44 | unsigned int getFrameNumber() const { return _frameNumber; } |
|---|
| 45 | |
|---|
| 46 | void setReferenceTime(double refTime) { _referenceTime = refTime; } |
|---|
| 47 | double getReferenceTime() const { return _referenceTime; } |
|---|
| 48 | |
|---|
| 49 | void setSimulationTime(double refTime) { _simulationTime = refTime; } |
|---|
| 50 | double getSimulationTime() const { return _simulationTime; } |
|---|
| 51 | |
|---|
| 52 | void setCalendarTime(const tm& calendarTime); |
|---|
| 53 | void getCalendarTime(tm& calendarTime) const; |
|---|
| 54 | |
|---|
| 55 | // keep public to allow it to be permit allocation which is |
|---|
| 56 | // not on the heap used osgcluster |
|---|
| 57 | virtual ~FrameStamp(); |
|---|
| 58 | |
|---|
| 59 | protected: |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 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 |
|---|
| 64 | // the network. |
|---|
| 65 | |
|---|
| 66 | unsigned int _frameNumber; |
|---|
| 67 | double _referenceTime; |
|---|
| 68 | double _simulationTime; |
|---|
| 69 | |
|---|
| 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]*/ |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | }; |
|---|
| 87 | |
|---|
| 88 | } |
|---|
| 89 | |
|---|
| 90 | |
|---|
| 91 | #endif |
|---|