OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FrameStamp.h
Go to the documentation of this file.
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 
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;
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
#define OSG_EXPORT
Definition: Export.h:43
void setReferenceTime(double refTime)
Definition: FrameStamp.h:46
double getSimulationTime() const
Definition: FrameStamp.h:50
double _referenceTime
Definition: FrameStamp.h:67
double getReferenceTime() const
Definition: FrameStamp.h:47
double _simulationTime
Definition: FrameStamp.h:68
void setSimulationTime(double refTime)
Definition: FrameStamp.h:49
Definition: AlphaFunc.h:19
void setFrameNumber(unsigned int fnum)
Definition: FrameStamp.h:43
unsigned int getFrameNumber() const
Definition: FrameStamp.h:44
unsigned int _frameNumber
Definition: FrameStamp.h:66