39 #if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT) 40 #error "Only <final/final.h> can be included directly." 43 #if !defined (__cplusplus) 44 #error "You need a C++ compiler like g++ or clang++" 45 #elif __cplusplus > 1 && __cplusplus < 201402L 46 #error "Your C++ compiler does not support the C++14 standard!" 55 #include "final/ftimer.h" 56 #include "final/ftypes.h" 57 #include "final/util/fstring.h" 83 using FObjectList = std::vector<FObject*>;
84 using iterator = FObjectList::iterator;
85 using reverse_iterator = FObjectList::reverse_iterator;
86 using const_iterator = FObjectList::const_iterator;
87 using const_reverse_iterator = FObjectList::const_reverse_iterator;
88 using reference = FObjectList::reference;
89 using const_reference = FObjectList::const_reference;
90 using difference_type = FObjectList::difference_type;
93 static constexpr
auto UNLIMITED =
static_cast<std::size_t
>(-1);
114 auto getClassName()
const ->
FString override;
115 auto getSelf()
const noexcept ->
FObject*;
116 auto getParent()
const noexcept ->
FObject*;
117 auto getChild (
int)
const ->
FObject*;
118 auto getChildren() noexcept -> FObjectList&;
119 auto getChildren()
const noexcept ->
const FObjectList&;
120 auto getMaxChildren()
const noexcept -> std::size_t;
121 auto numOfChildren()
const noexcept -> std::size_t;
122 auto begin() noexcept -> iterator;
123 auto end() noexcept -> iterator;
124 auto begin()
const noexcept -> const_iterator;
125 auto end()
const noexcept -> const_iterator;
126 auto cbegin()
const noexcept -> const_iterator;
127 auto cend()
const noexcept -> const_iterator;
128 auto rbegin() noexcept -> reverse_iterator;
129 auto rend() noexcept -> reverse_iterator;
130 auto rbegin()
const noexcept -> const_reverse_iterator;
131 auto rend()
const noexcept -> const_reverse_iterator;
132 auto crbegin()
const noexcept -> const_reverse_iterator;
133 auto crend()
const noexcept -> const_reverse_iterator;
134 auto front() -> reference;
135 auto back() -> reference;
136 auto front()
const -> const_reference;
137 auto back()
const -> const_reference;
140 void setMaxChildren (std::size_t) noexcept;
143 auto hasParent()
const noexcept -> bool;
144 auto hasChildren()
const noexcept -> bool;
145 auto isChild (
const FObject*)
const -> bool;
146 auto isDirectChild (
const FObject*)
const noexcept -> bool;
147 auto isWidget()
const noexcept -> bool;
148 auto isInstanceOf (
const FString&)
const -> bool;
157 virtual auto event (
FEvent*) -> bool;
161 void setWidgetProperty (
bool =
true) noexcept;
171 FObjectList children_list{};
172 std::size_t max_children{UNLIMITED};
173 bool has_parent{
false};
174 bool is_widget_object{
false};
179 inline auto FObject::getClassName()
const ->
FString 180 {
return "FObject"; }
183 inline auto FObject::getSelf()
const noexcept ->
FObject*
187 inline auto FObject::getParent()
const noexcept ->
FObject*
188 {
return parent_obj; }
191 inline auto FObject::getChildren() noexcept -> FObjectList&
192 {
return children_list; }
195 inline auto FObject::getChildren()
const noexcept ->
const FObjectList&
196 {
return children_list; }
199 inline auto FObject::getMaxChildren()
const noexcept -> std::size_t
200 {
return max_children; }
203 inline auto FObject::numOfChildren()
const noexcept -> std::size_t
204 {
return children_list.size(); }
207 inline auto FObject::begin() noexcept -> iterator
208 {
return children_list.begin(); }
211 inline auto FObject::end() noexcept -> iterator
212 {
return children_list.end(); }
215 inline auto FObject::begin()
const noexcept -> const_iterator
216 {
return children_list.begin(); }
219 inline auto FObject::end()
const noexcept -> const_iterator
220 {
return children_list.end(); }
223 inline auto FObject::cbegin()
const noexcept -> const_iterator
224 {
return children_list.cbegin(); }
227 inline auto FObject::cend()
const noexcept -> const_iterator
228 {
return children_list.cend(); }
231 inline auto FObject::rbegin() noexcept -> reverse_iterator
232 {
return children_list.rbegin(); }
235 inline auto FObject::rend() noexcept -> reverse_iterator
236 {
return children_list.rend(); }
239 inline auto FObject::rbegin()
const noexcept -> const_reverse_iterator
240 {
return children_list.rbegin(); }
243 inline auto FObject::rend()
const noexcept -> const_reverse_iterator
244 {
return children_list.rend(); }
247 inline auto FObject::crbegin()
const noexcept -> const_reverse_iterator
248 {
return children_list.crbegin(); }
251 inline auto FObject::crend()
const noexcept -> const_reverse_iterator
252 {
return children_list.crend(); }
255 inline auto FObject::front() -> reference
256 {
return children_list.front(); }
259 inline auto FObject::back() -> reference
260 {
return children_list.back(); }
263 inline auto FObject::front()
const -> const_reference
264 {
return children_list.front(); }
267 inline auto FObject::back()
const -> const_reference
268 {
return children_list.back(); }
271 inline void FObject::setMaxChildren (std::size_t max) noexcept
272 { max_children = max; }
275 inline auto FObject::hasParent()
const noexcept ->
bool 276 {
return has_parent; }
279 inline auto FObject::hasChildren()
const noexcept ->
bool 280 {
return ! children_list.empty(); }
283 inline auto FObject::isDirectChild (
const FObject* obj)
const noexcept ->
bool 284 {
return obj->getParent() ==
this; }
287 inline auto FObject::isWidget()
const noexcept ->
bool 288 {
return is_widget_object; }
291 inline auto FObject::isInstanceOf (
const FString& classname)
const ->
bool 292 {
return classname == getClassName(); }
295 inline void FObject::setWidgetProperty (
bool is_widget) noexcept
296 { is_widget_object = is_widget; }
Definition: class_template.cpp:25