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 getParent()
const & ->
FObject*;
116 auto getChild (
int)
const & ->
FObject*;
117 auto getChildren() & -> FObjectList&;
118 auto getChildren()
const & ->
const FObjectList&;
119 auto getMaxChildren()
const & noexcept -> std::size_t;
120 auto numOfChildren()
const & -> std::size_t;
121 auto begin() -> iterator;
122 auto end() -> iterator;
123 auto begin()
const -> const_iterator;
124 auto end()
const -> const_iterator;
125 auto cbegin()
const noexcept -> const_iterator;
126 auto cend()
const noexcept -> const_iterator;
127 auto rbegin() -> reverse_iterator;
128 auto rend() -> reverse_iterator;
129 auto rbegin()
const -> const_reverse_iterator;
130 auto rend()
const -> const_reverse_iterator;
131 auto crbegin()
const noexcept -> const_reverse_iterator;
132 auto crend()
const noexcept -> const_reverse_iterator;
133 auto front() -> reference;
134 auto back() -> reference;
135 auto front()
const -> const_reference;
136 auto back()
const -> const_reference;
139 void setMaxChildren (std::size_t) noexcept;
142 auto hasParent()
const & noexcept -> bool;
143 auto hasChildren()
const & -> bool;
144 auto isChild (
const FObject*)
const & -> bool;
145 auto isDirectChild (
const FObject*)
const & -> bool;
146 auto isWidget()
const noexcept -> bool;
147 auto isInstanceOf (
const FString&)
const -> bool;
150 void removeParent() &;
156 virtual auto event (
FEvent*) -> bool;
160 void setWidgetProperty (
bool =
true);
169 FObjectList children_list{};
170 std::size_t max_children{UNLIMITED};
171 bool has_parent{
false};
172 bool widget_object{
false};
177 inline auto FObject::getClassName()
const ->
FString 178 {
return "FObject"; }
181 inline auto FObject::getParent()
const & ->
FObject*
182 {
return parent_obj; }
185 inline auto FObject::getChildren() & -> FObjectList&
186 {
return children_list; }
189 inline auto FObject::getChildren()
const & ->
const FObjectList&
190 {
return children_list; }
193 inline auto FObject::getMaxChildren()
const & noexcept -> std::size_t
194 {
return max_children; }
197 inline auto FObject::numOfChildren()
const & -> std::size_t
198 {
return children_list.size(); }
201 inline auto FObject::begin() -> iterator
202 {
return children_list.begin(); }
205 inline auto FObject::end() -> iterator
206 {
return children_list.end(); }
209 inline auto FObject::begin()
const -> const_iterator
210 {
return children_list.begin(); }
213 inline auto FObject::end()
const -> const_iterator
214 {
return children_list.end(); }
217 inline auto FObject::cbegin()
const noexcept -> const_iterator
218 {
return children_list.cbegin(); }
221 inline auto FObject::cend()
const noexcept -> const_iterator
222 {
return children_list.cend(); }
225 inline auto FObject::rbegin() -> reverse_iterator
226 {
return children_list.rbegin(); }
229 inline auto FObject::rend() -> reverse_iterator
230 {
return children_list.rend(); }
233 inline auto FObject::rbegin()
const -> const_reverse_iterator
234 {
return children_list.rbegin(); }
237 inline auto FObject::rend()
const -> const_reverse_iterator
238 {
return children_list.rend(); }
241 inline auto FObject::crbegin()
const noexcept -> const_reverse_iterator
242 {
return children_list.crbegin(); }
245 inline auto FObject::crend()
const noexcept -> const_reverse_iterator
246 {
return children_list.crend(); }
249 inline auto FObject::front() -> reference
250 {
return children_list.front(); }
253 inline auto FObject::back() -> reference
254 {
return children_list.back(); }
257 inline auto FObject::front()
const -> const_reference
258 {
return children_list.front(); }
261 inline auto FObject::back()
const -> const_reference
262 {
return children_list.back(); }
265 inline void FObject::setMaxChildren (std::size_t max) noexcept
266 { max_children = max; }
269 inline auto FObject::hasParent()
const & noexcept ->
bool 270 {
return has_parent; }
273 inline auto FObject::hasChildren()
const & ->
bool 274 {
return ! children_list.empty(); }
277 inline auto FObject::isDirectChild (
const FObject* obj)
const & ->
bool 278 {
return obj->getParent() ==
this; }
281 inline auto FObject::isWidget()
const noexcept ->
bool 282 {
return widget_object; }
285 inline auto FObject::isInstanceOf (
const FString& classname)
const ->
bool 286 {
return classname == getClassName(); }
289 inline void FObject::setWidgetProperty (
bool is_widget)
290 { widget_object = is_widget; }
Definition: class_template.cpp:25