TrueReality  v0.1.1912
NodeBase.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 
22 #include <trBase/NodeBase.h>
23 
24 namespace trBase
25 {
26  const trUtil::RefStr NodeBase::CLASS_TYPE = trUtil::RefStr("trBase::NodeBase");
27 
29  NodeBase::NodeBase(const std::string name) : BaseClass(name)
30  {
31  mNode = new osg::Node(); //Creates our internal OSG node.
32  mNode->setName(name);
33  }
34 
37  {
38  }
39 
41  const std::string& NodeBase::GetType() const
42  {
43  return CLASS_TYPE;
44  }
45 
47  void NodeBase::SetName(const std::string& name)
48  {
49  BaseClass::SetName(name);
50  mNode->setName(name);
51  }
52 
54  osg::Node* NodeBase::AsOSGNode()
55  {
56  return mNode.Get();
57  }
58 
60  const osg::Node* NodeBase::AsOSGNode() const
61  {
62  return mNode.Get();
63  }
64 
67  {
68  return mUserData;
69  }
70 
73  {
74  return mUserData;
75  }
76 
79  {
80  mUserData = data;
81  }
82 
84 
85 
87 
89 }
virtual const std::string & GetType() const override
Returns the class type.
Definition: NodeBase.cpp:41
trBase::SmrtPtr< osg::Node > mNode
Definition: NodeBase.h:107
This class hold custom user data.
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
trBase::SmrtPtr< trBase::UserDataContainer > mUserData
Definition: NodeBase.h:116
~NodeBase()
dtor
Definition: NodeBase.cpp:36
virtual osg::Node * AsOSGNode()
Returns a pointer to the internal OSG Node.
Definition: NodeBase.cpp:54
This class is part of the internal garbage collection system.
Definition: SmrtClass.h:38
virtual void SetName(const std::string &name)
Sets this instances name.
Definition: NodeBase.cpp:47
virtual trBase::UserDataContainer * GetUserData()
Returns the custom user data that could be stored in the class instance Note, that if the user did no...
Definition: NodeBase.cpp:66
static const trUtil::RefStr CLASS_TYPE
Adds an easy and swappable access to the base class.
Definition: NodeBase.h:46
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
virtual void SetUserData(trBase::UserDataContainer *data)
Sets the user data for the current instance.
Definition: NodeBase.cpp:78
NodeBase(const std::string name=CLASS_TYPE)
ctor
Definition: NodeBase.cpp:29