OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
containerclass.h
1/*
2===========================================================================
3Copyright (C) 2025 the OpenMoHAA team
4
5This file is part of OpenMoHAA source code.
6
7OpenMoHAA source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12OpenMoHAA source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OpenMoHAA source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23// containerclass.h: C++ Class Container for use with SafePtr
24
25#pragma once
26
27#include "class.h"
28#include "container.h"
29
30template<class Type>
31class ContainerClass : public Class
32{
33 Container<Type> value;
34
35public:
36 ContainerClass();
37 ContainerClass(const Container<Type>& container);
38 ContainerClass<Type>& operator=(const Container<Type>& container);
39 ContainerClass(Container<Type>&& container);
40 ContainerClass<Type>& operator=(Container<Type>&& container);
41
42 ~ContainerClass() override;
43
44 void Archive(Archiver& arc) override;
45
46 int AddObject(const Type& obj);
47 int AddUniqueObject(const Type& obj);
48 void AddObjectAt(int index, const Type& obj);
49 Type *AddressOfObjectAt(int index);
50 void ClearObjectList(void);
51 void FreeObjectList(void);
52 int IndexOfObject(const Type& obj);
53 void InsertObjectAt(int index, const Type& obj);
54 int NumObjects(void) const;
55 Type& ObjectAt(const size_t index) const;
56 bool ObjectInList(const Type& obj);
57 void RemoveObjectAt(int index);
58 void RemoveObject(const Type& obj);
59 void Reset(void);
60 void Resize(int maxelements);
61 void SetObjectAt(int index, const Type& obj);
62 void Sort(int (*compare)(const void *elem1, const void *elem2));
63 Type& operator[](const int index) const;
64};
65
66template<typename Type>
67ContainerClass<Type>::ContainerClass()
68{}
69
70template<typename Type>
71ContainerClass<Type>::ContainerClass(const Container<Type>& container)
72 : value(container)
73{}
74
75template<typename Type>
76ContainerClass<Type>& ContainerClass<Type>::operator=(const Container<Type>& container)
77{
78 value = container;
79
80 return *this;
81}
82
83template<typename Type>
84ContainerClass<Type>::ContainerClass(Container<Type>&& container)
85 : value(std::move(container))
86{}
87
88template<typename Type>
89ContainerClass<Type>& ContainerClass<Type>::operator=(Container<Type>&& container)
90{
91 value = std::move(container);
92
93 return *this;
94}
95
96template<typename Type>
97ContainerClass<Type>::~ContainerClass()
98{
99 value.FreeObjectList();
100}
101
102template<typename Type>
103int ContainerClass<Type>::AddObject(const Type& obj)
104{
105 return value.AddObject(obj);
106}
107
108template<typename Type>
109int ContainerClass<Type>::AddUniqueObject(const Type& obj)
110{
111 return value.AddUniqueObject(obj);
112}
113
114template<typename Type>
115void ContainerClass<Type>::AddObjectAt(int index, const Type& obj)
116{
117 return value.AddObjectAt(index, obj);
118}
119
120template<typename Type>
121Type *ContainerClass<Type>::AddressOfObjectAt(int index)
122{
123 return value.AddressOfObjectAt(index);
124}
125
126template<typename Type>
127void ContainerClass<Type>::ClearObjectList(void)
128{
129 return value.ClearObjectList();
130}
131
132template<typename Type>
133void ContainerClass<Type>::FreeObjectList(void)
134{
135 return value.FreeObjectList();
136}
137
138template<typename Type>
139int ContainerClass<Type>::IndexOfObject(const Type& obj)
140{
141 return value.IndexOfObject(obj);
142}
143
144template<typename Type>
145void ContainerClass<Type>::InsertObjectAt(int index, const Type& obj)
146{
147 return value.InsertObjectAt(index, obj);
148}
149
150template<typename Type>
151int ContainerClass<Type>::NumObjects(void) const
152{
153 return value.NumObjects();
154}
155
156template<typename Type>
157Type& ContainerClass<Type>::ObjectAt(const size_t index) const
158{
159 return value.ObjectAt(index);
160}
161
162template<typename Type>
163bool ContainerClass<Type>::ObjectInList(const Type& obj)
164{
165 return value.ObjectInList(obj);
166}
167
168template<typename Type>
169void ContainerClass<Type>::RemoveObjectAt(int index)
170{
171 return value.RemoveObjectAt(index);
172}
173
174template<typename Type>
175void ContainerClass<Type>::RemoveObject(const Type& obj)
176{
177 return value.RemoveObject(obj);
178}
179
180template<typename Type>
181void ContainerClass<Type>::Reset(void)
182{
183 return value.Reset();
184}
185
186template<typename Type>
187void ContainerClass<Type>::Resize(int maxelements)
188{
189 return value.Resize(maxelements);
190}
191
192template<typename Type>
193void ContainerClass<Type>::SetObjectAt(int index, const Type& obj)
194{
195 return value.SetObjectAt(index, obj);
196}
197
198template<typename Type>
199void ContainerClass<Type>::Sort(int (*compare)(const void *elem1, const void *elem2))
200{
201 return value.Sort(compare);
202}
203
204template<typename Type>
205Type& ContainerClass<Type>::operator[](const int index) const
206{
207 return value[index];
208}
Definition archive.h:86
Definition containerclass.h:32
Definition container.h:85