TrueReality  v0.1.1912
FrameStamp.cpp
Go to the documentation of this file.
1 /*
2 * True Reality Open Source Game and Simulation Engine
3 * Copyright © 2021 Acid Rain Studios LLC
4 *
5 * This library is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License as published by the Free
7 * Software Foundation; either version 3.0 of the License, or (at your option)
8 * any later version.
9 *
10 * This library is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this library; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * @author Maxim Serebrennik
20 */
21 
23 
24 #include <trBase/Base.h>
25 
26 #include <osg/FrameStamp>
27 
28 namespace trCore::Nodes
29 {
30  const trUtil::RefStr FrameStamp::CLASS_TYPE = trUtil::RefStr("trCore::Nodes::FrameStamp");
31 
33  FrameStamp::FrameStamp(const std::string name)
34  {
35  mFrameStamp = new osg::FrameStamp();
36  BaseClass::SetName(name);
37  }
38 
40  FrameStamp::FrameStamp(const osg::FrameStamp fs, const std::string name)
41  {
42  mFrameStamp = new osg::FrameStamp(fs);
43  BaseClass::SetName(name);
44  }
45 
47  const std::string& FrameStamp::GetType() const
48  {
49  return CLASS_TYPE;
50  }
51 
53  void FrameStamp::SetName(const std::string& name)
54  {
55  BaseClass::SetName(name);
56  }
57 
59  osg::FrameStamp* FrameStamp::AsOSGClass()
60  {
61  return mFrameStamp.Get();
62  }
63 
65  const osg::FrameStamp* FrameStamp::AsOSGClass() const
66  {
67  return mFrameStamp.Get();
68  }
69 
71  void FrameStamp::SetFrameNumber(unsigned int fnum)
72  {
73  mFrameStamp->setFrameNumber(fnum);
74  }
75 
77  unsigned int FrameStamp::GetFrameNumber() const
78  {
79  return mFrameStamp->getFrameNumber();
80  }
81 
83  void FrameStamp::SetReferenceTime(double refTime)
84  {
85  mFrameStamp->setReferenceTime(refTime);
86  }
87 
90  {
91  return mFrameStamp->getReferenceTime();
92  }
93 
95  void FrameStamp::SetSimulationTime(double refTime)
96  {
97  mFrameStamp->setSimulationTime(refTime);
98  }
99 
102  {
103  return mFrameStamp->getSimulationTime();
104  }
105 
107  void FrameStamp::SetCalendarTime(const tm & calendarTime)
108  {
109  mFrameStamp->setCalendarTime(calendarTime);
110  }
111 
113  void FrameStamp::GetCalendarTime(tm & calendarTime) const
114  {
115  mFrameStamp->getCalendarTime(calendarTime);
116  }
117 
120  {
122  SetName(fs.GetName());
123  return *this;
124  }
125 
128  {
129  }
130 }
131 
virtual const std::string & GetType() const override
Returns the class type.
Definition: FrameStamp.cpp:47
virtual void SetName(const std::string &name)
Sets this instances name.
Definition: FrameStamp.cpp:53
double GetReferenceTime() const
Gets reference time.
Definition: FrameStamp.cpp:89
unsigned int GetFrameNumber() const
Gets frame number.
Definition: FrameStamp.cpp:77
virtual const std::string & GetName()
Returns this instances name.
Definition: Base.cpp:49
void SetReferenceTime(double refTime)
Sets reference time.
Definition: FrameStamp.cpp:83
static const trUtil::RefStr CLASS_TYPE
Adds an easy and swappable access to the base class.
Definition: FrameStamp.h:60
Class which encapsulates the frame number, reference time and calendar time of specific frame...
Definition: FrameStamp.h:54
A string wrapper that will make sure that all of the strings with the same value will point to the sa...
Definition: RefStr.h:50
void GetCalendarTime(tm &calendarTime) const
Gets calendar time.
Definition: FrameStamp.cpp:113
void SetCalendarTime(const tm &calendarTime)
Sets calendar time.
Definition: FrameStamp.cpp:107
FrameStamp & operator=(const FrameStamp &fs)
Assignment operator.
Definition: FrameStamp.cpp:119
double GetSimulationTime() const
Gets simulation time.
Definition: FrameStamp.cpp:101
trBase::SmrtPtr< osg::FrameStamp > mFrameStamp
The frame stamp.
Definition: FrameStamp.h:203
void SetSimulationTime(double refTime)
Sets simulation time.
Definition: FrameStamp.cpp:95
virtual osg::FrameStamp * AsOSGClass()
Returns a pointer to the internal OSG FrameStamp.
Definition: FrameStamp.cpp:59
void SetFrameNumber(unsigned int fnum)
Sets frame number.
Definition: FrameStamp.cpp:71
FrameStamp(const std::string name=CLASS_TYPE)
Holds the class type name for efficient comparisons.
Definition: FrameStamp.cpp:33
virtual void SetName(const std::string &name)
Sets this instances name.
Definition: Base.cpp:43
T * Get() const
Returns the stored internal pointer.
Definition: SmrtPtr.h:73