TrueReality  v0.1.1912
UserDataContainer.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 
25 namespace trBase
26 {
27  const trUtil::RefStr UserDataContainer::CLASS_TYPE = trUtil::RefStr("trBase::UserDataContainer");
28 
30  UserDataContainer::UserDataContainer(const std::string name) : BaseClass(name)
31  {
32  }
33 
36  {
37  }
38 
40  const std::string& UserDataContainer::GetType() const
41  {
42  return CLASS_TYPE;
43  }
44 
47  {
48  return mUserDataContainer;
49  }
50 
53  {
54  return mUserDataContainer;
55  }
56 
59  {
60  mUserDataContainer = data;
61  }
62 
64  std::vector<std::string> UserDataContainer::GetDescriptionList()
65  {
66  return mDescriptionList;
67  }
68 
70  const std::vector<std::string> UserDataContainer::GetDescriptionList() const
71  {
72  return mDescriptionList;
73  }
74 
77  {
78  return mDescriptionList.size();
79  }
80 
82  std::string UserDataContainer::GetDescription(int index)
83  {
84  return mDescriptionList[index];
85  }
86 
88  const std::string UserDataContainer::GetDescription(int index) const
89  {
90  return mDescriptionList[index];
91  }
92 
94  void UserDataContainer::AddDescription(std::string description)
95  {
96  mDescriptionList.push_back(description);
97  }
98 
100  void UserDataContainer::SetDescriptions(std::vector<std::string> descriptions)
101  {
102  mDescriptionList = descriptions;
103  }
104 
106  std::vector<trBase::SmrtPtr<trBase::Base>> UserDataContainer::GetObjectList()
107  {
108  return mObjectList;
109  }
110 
112  const std::vector<trBase::SmrtPtr<trBase::Base>> UserDataContainer::GetObjectList() const
113  {
114  return mObjectList;
115  }
116 
119  {
120  return mObjectList.size();
121  }
122 
125  {
126  return mObjectList[index];
127  }
128 
131  {
132  return mObjectList[index];
133  }
134 
137  {
138  return mObjectList.push_back(obj);
139  }
140 
143  {
144  mObjectList = objList;
145  }
146 }
virtual std::string GetDescription(int index=0)
Returns the specified description.
virtual void SetUserDataContainer(trBase::SmrtClass *data)
Sets the user data object.
std::vector< trBase::SmrtPtr< trBase::Base > > mObjectList
virtual std::vector< trBase::SmrtPtr< trBase::Base > > GetObjectList()
Returns the list of all the user objects cast down to Base class.
static const trUtil::RefStr CLASS_TYPE
Adds an easy and swappable access to the base class.
UserDataContainer(const std::string name=CLASS_TYPE)
Holds the class type name for efficient comparisons.
Smart pointer for handling referenced counted objects.
Definition: SmrtPtr.h:36
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
This class is part of the internal garbage collection system.
Definition: SmrtClass.h:38
std::vector< std::string > mDescriptionList
trBase::SmrtPtr< trBase::SmrtClass > mUserDataContainer
virtual std::vector< std::string > GetDescriptionList()
Returns a list of Description strings.
virtual int GetObjectListCount()
Returns the number of objects stored in the Object list.
virtual void SetObjects(std::vector< trBase::SmrtPtr< trBase::Base >> objList)
Set a new list of objects.
virtual trBase::SmrtClass * GetUserDataContainer()
Returns the user data object.
virtual trBase::SmrtPtr< trBase::Base > GetObject(int index=0)
Returns the specified object.
virtual void SetDescriptions(std::vector< std::string > descriptions)
Set a new list of descriptions strings.
virtual void AddDescription(std::string description)
Adds a new description string to the list of descriptions.
virtual void AddObject(trBase::SmrtPtr< trBase::Base > obj)
Adds a new object to the object list.
virtual int GetDescriptionListCount()
Returns the number of objects stored in the Description list.
virtual const std::string & GetType() const override
Returns the class type.