TrueReality  v0.1.1912
trSG/Node.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 <trSG/Node.h>
23 
24 #include <trBase/Base.h>
25 
26 #include <osg/Node>
27 
28 namespace trSG
29 {
30  const trUtil::RefStr Node::CLASS_TYPE = trUtil::RefStr("trSG::Node");
31 
33  Node::Node(const std::string name) : BaseClass(name)
34  {
35  mNode = new osg::Node(); //Creates our internal OSG node.
36  mNode->setName(name);
37  }
38 
41  {
42  }
43 
45  const std::string& Node::GetType() const
46  {
47  return CLASS_TYPE;
48  }
49 
51  void Node::SetName(const std::string& name)
52  {
53  BaseClass::SetName(name);
54  mNode->setName(name);
55  }
56 
58  osg::Node* Node::AsOSGNode()
59  {
60  return mNode.Get();
61  }
62 
64  const osg::Node* Node::AsOSGNode() const
65  {
66  return mNode.Get();
67  }
68 
70 
71 
73 
75 }
static const trUtil::RefStr CLASS_TYPE
Adds an easy and swappable access to the base class.
Definition: trSG/Node.h:55
virtual osg::Node * AsOSGNode()
Returns a pointer to the internal OSG Node.
Definition: trSG/Node.cpp:58
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
~Node()
dtor.
Definition: trSG/Node.cpp:40
This class is part of the internal garbage collection system.
Definition: SmrtClass.h:38
Node(const std::string name=CLASS_TYPE)
Constructor.
Definition: trSG/Node.cpp:33
trBase::SmrtPtr< osg::Node > mNode
Visitor Pattern : calls the apply method of a NodeVisitor with this node&#39;s type.
Definition: trSG/Node.h:128
Definition: trSG/Node.h:42
virtual const std::string & GetType() const override
Returns the class type.
Definition: trSG/Node.cpp:45
virtual void SetName(const std::string &name)
Sets this instances name.
Definition: Base.cpp:43
virtual void SetName(const std::string &name)
Sets this instances name.
Definition: trSG/Node.cpp:51
T * Get() const
Returns the stored internal pointer.
Definition: SmrtPtr.h:73