Gorgon Game Engine
Data.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Base.h"
4 #include "Reader.h"
5 #include "DataItems.h"
6 #include "../TMP.h"
7 
8 #include <functional>
9 
10 namespace Gorgon { namespace Resource {
11 
12  class File;
13 
14  class Data : public Base {
15 
16  template <class T_, class R_, int IND_>
17  void append(const T_ &values, const std::string &prefix, const R_ &reflectionobj) {
18  Append(prefix+reflectionobj.Names[IND_], values.*(R_::template Member<IND_>::MemberPointer()) );
19  }
20 
21 
22  template <class T_, class R_, int ...S_>
23  void append(const T_ &values, const std::string &prefix, const R_ &reflectionobj, TMP::Sequence<S_...>) {
24  char dummy[] ={0, (append<T_, R_, S_>(values, prefix, reflectionobj),'\0')...};
25  }
26 
27  template <class T_, class O_, class R_, int IND_>
28  typename std::enable_if<!std::is_base_of<Base, typename std::remove_pointer<O_>::type>::value, void>::type
29  namedtransform(T_ &values, const std::string &prefix, const R_ &reflectionobj) const {
30  values.*(R_::template Member<IND_>::MemberPointer())=GetItem(prefix+reflectionobj.Names[IND_]).template Get<O_>();
31  }
32 
33  template <class T_, class R_, int ...S_>
34  void namedtransform(T_ &values, const std::string &prefix, const R_ &reflectionobj, TMP::Sequence<S_...>) const {
35  char dummy[] ={0, (namedtransform<T_, typename R_::template Member<S_>::Type, R_, S_>(values, prefix, reflectionobj),'\0')...};
36  }
37 
38  template <class T_, class O_, class R_, int IND_>
39  typename std::enable_if<std::is_base_of<Base, typename std::remove_pointer<O_>::type>::value, void>::type
40  namedtransform(T_ &values, const std::string &prefix, const R_ &reflectionobj) {
41  values.*(R_::template Member<IND_>::MemberPointer())=&GetItem(prefix+reflectionobj.Names[IND_]).template GetObject<typename std::remove_pointer<O_>::type>();
42  dynamic_cast<ObjectData&>(GetItem(prefix+reflectionobj.Names[IND_])).Release();
43  }
44 
45  template <class T_, class O_, class R_, int IND_>
46  typename std::enable_if<!std::is_base_of<Base, typename std::remove_pointer<O_>::type>::value, void>::type
47  namedtransform(T_ &values, const std::string &prefix, const R_ &reflectionobj) {
48  values.*(R_::template Member<IND_>::MemberPointer())=GetItem(prefix+reflectionobj.Names[IND_]).template Get<O_>();
49  }
50 
51  template <class T_, class R_, int ...S_>
52  void namedtransform(T_ &values, const std::string &prefix, const R_ &reflectionobj, TMP::Sequence<S_...>) {
53  char dummy[] ={0, (namedtransform<T_, typename R_::template Member<S_>::Type, R_, S_>(values, prefix, reflectionobj),'\0')...};
54  }
55 
56  public:
59 
62 
64  Data() { }
65 
69  template<class T_, class R_ = typename T_::ReflectionType>
70  explicit Data(const T_ &values, const R_ &reflectionobj = T_::Reflection()) {
71  Append(values, reflectionobj);
72  }
73 
78  template<class T_, class R_ = typename T_::ReflectionType>
79  Data(const T_ &values, const std::string &prefix, const R_ &reflectionobj = T_::Reflection()) {
80  Append(values, prefix, reflectionobj);
81  }
82 
83  virtual GID::Type GetGID() const override {
84  return GID::Data;
85  }
86 
91  template<class T_, class R_ = typename T_::ReflectionType>
92  typename std::enable_if<R_::IsGorgonReflection, void>::type
93  Append(const T_ &values, const R_ &reflectionobj = T_::Reflection()) {
94  static_assert(R_::IsGorgonReflection, "The template argument R_ for this constructor should be reflection type of the struct.");
95 
96  Append(values, "", reflectionobj);
97  }
98 
103  template<class T_, class R_ = typename T_::ReflectionType>
104  typename std::enable_if<R_::IsGorgonReflection, void>::type
105  Append(const T_ &values, const std::string &prefix, const R_ &reflectionobj = T_::Reflection()) {
106  static_assert(R_::IsGorgonReflection, "The template argument R_ for this constructor should be reflection type of the struct.");
107 
108  append(values, prefix, reflectionobj, typename TMP::Generate<R_::MemberCount>::Type());
109  }
110 
112  template<class T_>
113  typename std::enable_if<!std::is_base_of<Base, T_>::value && !T_::ReflectionType::IsGorgonReflection, void>::type
114  Append(T_ value) {
115  Insert(value, items.GetCount());
116  }
117 
119  template<class T_>
120  typename std::enable_if<std::is_base_of<Base, T_>::value, void>::type
121  Append(T_ &value) {
122  Insert(value, items.GetCount());
123  }
124 
126  template<class T_>
127  typename std::enable_if<!std::is_base_of<Base, T_>::value, void>::type
128  Append(const std::string &name, T_ value) {
129  Insert(name, value, items.GetCount());
130  }
131 
133  template<class T_>
134  typename std::enable_if<std::is_base_of<Base, T_>::value, void>::type
135  Append(const std::string &name, T_ &value) {
136  Insert(name, value, items.GetCount());
137  }
138 
140  void Insert(int value, int before) {
141  Insert("#"+String::From(items.GetCount()), value, before);
142  }
143 
145  void Insert(const std::string &name, int value, int before) {
146  items.Insert(new IntegerData(name, value), before);
147  }
148 
150  void Insert(float value, int before) {
151  Insert("#"+String::From(items.GetCount()), value, before);
152  }
153 
155  void Insert(const std::string &name, float value, int before) {
156  items.Insert(new FloatData(name, value), before);
157  }
158 
160  void Insert(const std::string &value, int before) {
161  Insert("#"+String::From(items.GetCount()), value, before);
162  }
163 
165  void Insert(const std::string &name, const std::string &value, int before) {
166  items.Insert(new TextData(name, value), before);
167  }
168 
170  void Insert(const char *value, int before) {
171  Insert("#"+String::From(items.GetCount()), value, before);
172  }
173 
175  void Insert(const std::string &name, const char *value, int before) {
176  items.Insert(new TextData(name, value), before);
177  }
178 
180  void Insert(Geometry::Point value, int before) {
181  Insert("#"+String::From(items.GetCount()), value, before);
182  }
183 
185  void Insert(const std::string &name, Geometry::Point value, int before) {
186  items.Insert(new PointData(name, value), before);
187  }
188 
190  void Insert(Geometry::Pointf value, int before) {
191  Insert("#"+String::From(items.GetCount()), value, before);
192  }
193 
195  void Insert(const std::string &name, Geometry::Pointf value, int before) {
196  items.Insert(new PointfData(name, value), before);
197  }
198 
200  void Insert(Geometry::Size value, int before) {
201  Insert("#"+String::From(items.GetCount()), value, before);
202  }
203 
205  void Insert(const std::string &name, Geometry::Size value, int before) {
206  items.Insert(new SizeData(name, value), before);
207  }
208 
210  void Insert(Geometry::Rectangle value, int before) {
211  Insert("#"+String::From(items.GetCount()), value, before);
212  }
213 
215  void Insert(const std::string &name, Geometry::Rectangle value, int before) {
216  items.Insert(new RectangleData(name, value), before);
217  }
218 
220  void Insert(Geometry::Bounds value, int before) {
221  Insert("#"+String::From(items.GetCount()), value, before);
222  }
223 
225  void Insert(const std::string &name, Geometry::Bounds value, int before) {
226  items.Insert(new BoundsData(name, value), before);
227  }
228 
230  void Insert(Geometry::Margin value, int before) {
231  Insert("#"+String::From(items.GetCount()), value, before);
232  }
233 
234  void Insert(const std::string &name, Geometry::Margin value, int before) {
235  items.Insert(new MarginData(name, value), before);
236  }
237 
239  void Insert(Base *value, int before) {
240  Insert("#"+String::From(items.GetCount()), value, before);
241  }
242 
244  void Insert(const std::string &name, Base *value, int before) {
245  items.Insert(new ObjectData(name, value), before);
246  }
247 
249  void Insert(Base &value, int before) {
250  Insert(&value, before);
251  }
252 
254  void Insert(const std::string &name, Base &value, int before) {
255  Insert(name, &value, before);
256  }
257 
260  template<class T_, class R_ = typename T_::ReflectionType>
261  T_ NamedTransform_KeepObjects(const R_ &reflectionobj = T_::Reflection()) const {
262  return NamedTransform_KeepObjects<T_, R_>("", reflectionobj);
263  }
264 
267  template<class T_, class R_ = typename T_::ReflectionType>
268  T_ NamedTransform_KeepObjects(const std::string &prefix, const R_ &reflectionobj = T_::Reflection()) const {
269  T_ t;
270  namedtransform<T_, R_>(t, prefix, reflectionobj, typename TMP::Generate<R_::MemberCount>::Type());
271 
272  return t;
273  }
274 
277  template<class T_, class R_ = typename T_::ReflectionType>
278  T_ NamedTransform(const R_ &reflectionobj = T_::Reflection()) {
279  return NamedTransform<T_, R_>("", reflectionobj);
280  }
281 
284  template<class T_, class R_ = typename T_::ReflectionType>
285  T_ NamedTransform(const std::string &prefix, const R_ &reflectionobj = T_::Reflection()) {
286  T_ t;
287  namedtransform<T_, R_>(t, prefix, reflectionobj, typename TMP::Generate<R_::MemberCount>::Type());
288 
289  return t;
290  }
291 
293  template<class T_>
294  T_ Get(int index) const {
295  static_assert(std::is_same<T_, int>::value, "Unknown data type.");
296  }
297 
299  template<class T_>
300  T_ Get(const std::string &name) const {
301  static_assert(std::is_same<T_, int>::value, "Unknown data type.");
302  }
303 
305  template<class T_>
306  T_ &GetObject(int index) const {
307  auto &item=dynamic_cast<ObjectData&>(items[index]);
308 
309  return item.Get<T_>();
310  }
311 
313  template<class T_>
314  T_ &GetObject(const std::string &name) const {
316  }
317 
320  return items.begin();
321  }
322 
324  ConstIterator end() const {
325  return items.end();
326  }
327 
330  return items.begin();
331  }
332 
335  return items.end();
336  }
337 
339  DataItem &GetItem(int index) const {
340  return items[index];
341  }
342 
344  DataItem &GetItem(const std::string &name) const {
345  for(auto &item : items) {
346  if(item.Name==name) return item;
347  }
348 
349  throw std::runtime_error("Cannot find the item requested: "+name);
350  }
351 
354  int FindIndex(const std::string &name) const {
355  int ind=0;
356  for(auto &item : items) {
357  if(item.Name==name) return ind;
358  ind++;
359  }
360 
361  return -1;
362  }
363 
365  int GetCount() const {
366  return items.GetCount();
367  }
368 
370  void Remove(int index) {
371  items.Delete(index);
372  }
373 
375  void Remove(const std::string &name) {
376  int ind = FindIndex(name);
377 
378  if(ind==-1) {
379  throw std::runtime_error("Cannot find the item with the name: "+name);
380  }
381 
382  Remove(ind);
383  }
384 
386  DataItem &Release(int index) {
387  auto &item = items[index];
388 
389  items.Remove(index);
390 
391  return item;
392  }
393 
395  DataItem &Release(const std::string &name) {
396  int ind = FindIndex(name);
397 
398  if(ind==-1) {
399  throw std::runtime_error("Cannot find the item with the name: "+name);
400  }
401 
402  return Release(ind);
403  }
404 
406  void Add(DataItem &item) {
407  items.Add(item);
408  }
409 
411  void Insert(DataItem &item, int before) {
412  items.Insert(item, before);
413  }
414 
416  static Data *LoadResource(std::weak_ptr<File> file, std::shared_ptr<Reader> reader, unsigned long totalsize);
417 
418  protected:
420  ~Data() {
421  items.Destroy();
422  }
423 
424  private:
425  virtual void save(Writer &writer) const;
426 
428 
429 
430  };
431 
432  template<>
433  inline int Data::Get<int>(int index) const {
434  auto &item=dynamic_cast<IntegerData&>(items[index]);
435 
436  return item.Get();
437  }
438 
439  template<>
440  inline float Data::Get<float>(int index) const {
441  auto &item=dynamic_cast<FloatData&>(items[index]);
442 
443  return item.Get();
444  }
445 
446  template<>
447  inline std::string Data::Get<std::string>(int index) const {
448  auto &item=dynamic_cast<TextData&>(items[index]);
449 
450  return item.Get();
451  }
452 
453  template<>
454  inline Geometry::Point Data::Get<Geometry::Point>(int index) const {
455  auto &item=dynamic_cast<PointData&>(items[index]);
456 
457  return item.Get();
458  }
459 
460  template<>
461  inline Geometry::Pointf Data::Get<Geometry::Pointf>(int index) const {
462  auto &item=dynamic_cast<PointfData&>(items[index]);
463 
464  return item.Get();
465  }
466 
467  template<>
468  inline Geometry::Size Data::Get<Geometry::Size>(int index) const {
469  auto &item=dynamic_cast<SizeData&>(items[index]);
470 
471  return item.Get();
472  }
473 
474  template<>
475  inline Geometry::Rectangle Data::Get<Geometry::Rectangle>(int index) const {
476  auto &item=dynamic_cast<RectangleData&>(items[index]);
477 
478  return item.Get();
479  }
480 
481  template<>
482  inline Geometry::Bounds Data::Get<Geometry::Bounds>(int index) const {
483  auto &item=dynamic_cast<BoundsData&>(items[index]);
484 
485  return item.Get();
486  }
487 
488  template<>
489  inline Geometry::Margin Data::Get<Geometry::Margin>(int index) const {
490  auto &item=dynamic_cast<MarginData&>(items[index]);
491 
492  return item.Get();
493  }
494 
495 
496 } }
Gorgon::Scripting::Data::isreference
bool isreference
Is a reference, data is a ptr to the original type.
Definition: Data.h:191
Gorgon::Resource::Data::NamedTransform_KeepObjects
T_ NamedTransform_KeepObjects(const R_ &reflectionobj=T_::Reflection()) const
Transforms the members of this resource data to the given struct.
Definition: Data.h:261
Gorgon::Resource::Data::Insert
void Insert(Geometry::Size value, int before)
Inserts a data item to the given position.
Definition: Data.h:200
Gorgon::Resource::PointfData
Definition: DataItems.h:183
Gorgon::Geometry::basic_Bounds
This class represents boundaries of 2D objects.
Definition: Bounds.h:27
Gorgon::Resource::Data::Data
Data(const T_ &values, const std::string &prefix, const R_ &reflectionobj=T_::Reflection())
This constructor accepts a reflected struct and turns it into a resource data.
Definition: Data.h:79
Gorgon::Resource::Data::Insert
void Insert(Geometry::Margin value, int before)
Inserts a data item to the given position.
Definition: Data.h:230
Gorgon::Scripting::VirtualMachine::Exists
static bool Exists()
Returns the current VM for this thread.
Definition: VirtualMachine.h:118
Gorgon::Scripting::Data::DeReference
Data DeReference()
Definition: Data.cpp:180
Gorgon::Scripting::Data::data
Any data
Stored data.
Definition: Data.h:185
Gorgon::Scripting::Type::ToString
virtual std::string ToString(const Data &) const =0
Converts a data of this type to string.
Gorgon::Resource::GID::File
constexpr Type File
File.
Definition: GID.h:84
Gorgon::String::From
std::enable_if< decltype(gorgon__enum_tr_loc(T_()))::isupgradedenum, std::string >::type From(const T_ &e)
Definition: Enum.h:303
Gorgon::Resource::Base::name
std::string name
Name of this resource object, may not be loaded.
Definition: Base.h:155
Gorgon::Resource::GID::Data
constexpr Type Data
Data resource.
Definition: GID.h:164
Gorgon::Resource::Data::Append
std::enable_if<!std::is_base_of< Base, T_ >::value &&!T_::ReflectionType::IsGorgonReflection, void >::type Append(T_ value)
Appends the given data to the end of this data resource.
Definition: Data.h:114
Gorgon::Resource::Data::Insert
void Insert(Geometry::Point value, int before)
Inserts a data item to the given position.
Definition: Data.h:180
Gorgon::TMP::RTTH::ConstPtrType
RTTS & ConstPtrType
Definition: TMP.h:375
File.h
Gorgon::Resource::Data::GetGID
virtual GID::Type GetGID() const override
This function shall return Gorgon ID of this resource.
Definition: Data.h:83
Gorgon::Resource::Data::Append
std::enable_if< std::is_base_of< Base, T_ >::value, void >::type Append(T_ &value)
Appends the given resource object to the end of this data resource.
Definition: Data.h:121
Gorgon::Scripting::Data::~Data
virtual ~Data()
Definition: Data.cpp:128
Gorgon::Resource::Data::NamedTransform
T_ NamedTransform(const R_ &reflectionobj=T_::Reflection())
Transforms the members of this resource data to the given struct.
Definition: Data.h:278
Gorgon::Resource::Data::Insert
void Insert(int value, int before)
Inserts a data item to the given position.
Definition: Data.h:140
Gorgon::Scripting::ReferenceCounter::Register
void Register(const Data &data)
Registers a new object of reference counting, this will set reference count to one.
Definition: Runtime.h:24
Gorgon::Resource::Data::Insert
void Insert(const std::string &name, Base *value, int before)
Inserts a data item to the given position with the specified name.
Definition: Data.h:244
Gorgon::Scripting::Type::Delete
void Delete(const Data &obj) const
Deletes the object.
Definition: Reflection.h:1379
Gorgon::Resource::Data::Insert
void Insert(Geometry::Rectangle value, int before)
Inserts a data item to the given position.
Definition: Data.h:210
Gorgon::Scripting::Data::Data
Data()
Constructs an invalid data.
Definition: Data.h:31
Base.h
Gorgon::Resource::FloatData
Definition: DataItems.h:104
Gorgon::Resource::Data::~Data
~Data()
Destructor.
Definition: Data.h:420
Gorgon::Scripting::Type::TypeInterface
TMP::RTTH & TypeInterface
Type interface used for this type.
Definition: Reflection.h:1414
Gorgon::Any
This class can hold any other information providing type erasure.
Definition: Any.h:32
Gorgon::Scripting::VirtualMachine::References
ReferenceCounter References
This system allows objects of automatic lifetime.
Definition: VirtualMachine.h:222
Reader.h
Gorgon::Resource::Data::end
Iterator end()
Can be used to iterate over data objects.
Definition: Data.h:334
Gorgon::Scripting::Data
Data describes a piece of data.
Definition: Data.h:22
Gorgon::Scripting::Data::ToString
std::string ToString() const
Definition: Data.cpp:90
Gorgon::Resource::RectangleData
Definition: DataItems.h:237
Gorgon::Resource::Data::Insert
void Insert(DataItem &item, int before)
Inserts the given data item to this data resource before the specified index. Ownership of the item i...
Definition: Data.h:411
Gorgon::Any::UnsafeGet
T_ UnsafeGet() const
Unsafe version of Get.
Definition: Any.h:305
Gorgon::Resource::DataItem
Definition: DataItems.h:17
Gorgon::Resource::Data::Insert
void Insert(const std::string &name, Geometry::Size value, int before)
Inserts a data item to the given position with the specified name.
Definition: Data.h:205
Gorgon::Resource::Data::LoadResource
static Data * LoadResource(std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long totalsize)
Loads a data resource.
Definition: Data.cpp:18
Gorgon::Any::SetRaw
void SetRaw(void *data)
Unsafe! This function sets the raw data contained within any, without modifying its type data.
Definition: Any.h:194
Gorgon::Resource::Data::Insert
void Insert(const std::string &name, Geometry::Pointf value, int before)
Inserts a data item to the given position with the specified name.
Definition: Data.h:195
Gorgon::Resource::Data::Insert
void Insert(const std::string &name, int value, int before)
Inserts a data item to the given position with the specified name.
Definition: Data.h:145
Gorgon::TMP::Sequence
A sequence element, can be used to represent a sequence of integer numbers.
Definition: TMP.h:15
Gorgon::Scripting::Type::Compare
bool Compare(const Data &l, const Data &r) const
This function compares two instances of this type. Both left and right should of this type.
Definition: Reflection.cpp:95
Gorgon::Resource::Data::Insert
void Insert(const std::string &name, Geometry::Margin value, int before)
Definition: Data.h:234
Gorgon::Any::Disown
void * Disown()
Unsafe! Disowns the data contained in this any.
Definition: Any.h:234
Gorgon::Resource::Data::Insert
void Insert(const std::string &name, Geometry::Point value, int before)
Inserts a data item to the given position with the specified name.
Definition: Data.h:185
Gorgon::Scripting::VirtualMachine::Get
static VirtualMachine & Get()
Returns the current VM for this thread.
Definition: VirtualMachine.h:109
Gorgon::Scripting::Type::IsReferenceType
bool IsReferenceType() const
Returns whether this type is a reference type.
Definition: Reflection.h:1327
Gorgon::Resource::Data::Insert
void Insert(const std::string &name, float value, int before)
Inserts a data item to the given position with the specified name.
Definition: Data.h:155
Gorgon::Resource::TextData
Definition: DataItems.h:130
Gorgon::TMP::Generate
Generates a sequence from 0 to the given value.
Definition: TMP.h:18
Gorgon::Resource::Data::Release
DataItem & Release(int index)
Releases the data item with the given index. The data item will not be destroyed.
Definition: Data.h:386
Gorgon::Utils::ASSERT_FALSE
void ASSERT_FALSE(const std::string &message, int skip=1, int depth=4)
Definition: Assert.h:192
Gorgon::Resource::Data::Insert
void Insert(Base *value, int before)
Inserts a data item to the given position.
Definition: Data.h:239
Gorgon::Resource::Data::Append
std::enable_if<!std::is_base_of< Base, T_ >::value, void >::type Append(const std::string &name, T_ value)
Appends the given data to the end of this data resource with the specified name.
Definition: Data.h:128
Gorgon::Resource::Data::Add
void Add(DataItem &item)
Adds the given data item to this data resource. Ownership of the item is transferred to this Data.
Definition: Data.h:406
Gorgon::Resource::Data::NamedTransform_KeepObjects
T_ NamedTransform_KeepObjects(const std::string &prefix, const R_ &reflectionobj=T_::Reflection()) const
Transforms the members of this resource data to the given struct.
Definition: Data.h:268
Gorgon::Any::SetType
void SetType(const TMP::RTTS &type)
Unsafe! This function modifies type information of the data content.
Definition: Any.h:246
Gorgon::Scripting::Data::MakeConstant
void MakeConstant()
Makes this data a constant.
Definition: Data.cpp:199
Gorgon::Scripting::Type
This class stores information about types.
Definition: Reflection.h:1165
Gorgon
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
Gorgon::Geometry::basic_Size
This class represents a 2D geometric size.
Definition: Size.h:23
Gorgon::Resource::Data::FindIndex
int FindIndex(const std::string &name) const
Returns the index of the data item with the given name.
Definition: Data.h:354
Gorgon::TMP::RTTH::NormalType
RTTS & NormalType
Definition: TMP.h:375
Gorgon::Resource::Data::begin
ConstIterator begin() const
Can be used to iterate over data objects.
Definition: Data.h:319
Gorgon::Scripting::Data::GetReference
Data GetReference()
Definition: Data.cpp:148
Gorgon::Resource::Data::Insert
void Insert(const std::string &name, const std::string &value, int before)
Inserts a data item to the given position with the specified name.
Definition: Data.h:165
Gorgon::Resource::Data::Insert
void Insert(Base &value, int before)
Inserts a data item to the given position.
Definition: Data.h:249
Gorgon::Resource::ObjectData
Definition: DataItems.h:324
Gorgon::Resource::ObjectData::Get
T_ & Get() const
Returns the item contained within this object.
Definition: DataItems.h:391
Gorgon::Scripting::Data::IsReference
bool IsReference() const
Returns if this data contains a reference.
Definition: Data.cpp:212
ASSERT
#define ASSERT(expression, message,...)
Replaces regular assert to allow messages and backtrace.
Definition: Assert.h:161
Gorgon::Containers::Collection
Collection is a container for reference typed objects.
Definition: Collection.h:21
Gorgon::Resource::DataItem::DataLoaders
static std::map< GID::Type, LoaderFn > DataLoaders
Data loaders that all data containing classes would use to load their children.
Definition: DataItems.h:58
Gorgon::Any::TypeInfo
TMP::RTTI & TypeInfo() const
Returns TypeInfo used by current data.
Definition: Any.h:87
Gorgon::Scripting::Data::operator==
bool operator==(const Data &r) const
Definition: Data.cpp:218
Gorgon::Resource::Data::GetItem
DataItem & GetItem(int index) const
Returns the data item with the given index.
Definition: Data.h:339
VirtualMachine.h
Gorgon::Resource::Base
This class is the base for all Gorgon Resources.
Definition: Base.h:20
Gorgon::Resource::Data::Insert
void Insert(const std::string &name, const char *value, int before)
Inserts a data item to the given position with the specified name.
Definition: Data.h:175
Gorgon::Resource::Data::GetItem
DataItem & GetItem(const std::string &name) const
Returns the data item with the given name.
Definition: Data.h:344
Gorgon::Resource::IntegerData
Definition: DataItems.h:78
Gorgon::Resource::SizeData
Definition: DataItems.h:210
Gorgon::Resource::Data::Append
std::enable_if< R_::IsGorgonReflection, void >::type Append(const T_ &values, const R_ &reflectionobj=T_::Reflection())
This function accepts a reflected struct and appends it to the resource data.
Definition: Data.h:93
Gorgon::Resource::Data::end
ConstIterator end() const
Can be used to iterate over data objects.
Definition: Data.h:324
Gorgon::Resource::Data::Iterator
Containers::Collection< DataItem >::Iterator Iterator
Iterator for the data resource.
Definition: Data.h:58
Gorgon::Containers::Collection::ConstIterator
Const iterator allows iteration of const collections.
Definition: Collection.h:137
Gorgon::Containers::Collection::Iterator
Iterator_< T_, Collection > Iterator
Regular iterator.
Definition: Collection.h:134
Gorgon::Resource::MarginData
Definition: DataItems.h:295
Gorgon::Resource::Data::NamedTransform
T_ NamedTransform(const std::string &prefix, const R_ &reflectionobj=T_::Reflection())
Transforms the members of this resource data to the given struct.
Definition: Data.h:285
Gorgon::Resource::Data::Insert
void Insert(const char *value, int before)
Inserts a data item to the given position.
Definition: Data.h:170
Gorgon::Geometry::basic_Point
This class represents a 2D point.
Definition: Point.h:32
Gorgon::Scripting::Type::GetDefaultValue
Any GetDefaultValue() const
Returns the value of the type.
Definition: Reflection.h:1322
Gorgon::Resource::Writer
This class allows resource objects to save their data to a stream.
Definition: Writer.h:59
Gorgon::Resource::Data::Insert
void Insert(Geometry::Pointf value, int before)
Inserts a data item to the given position.
Definition: Data.h:190
Gorgon::Scripting::Data::Delete
void Delete() const
Attempts to delete the data contained in this data.
Definition: Data.cpp:136
Gorgon::Scripting::Data::IsNull
bool IsNull() const
Definition: Data.cpp:118
Gorgon::Any::Set
void Set(const T_ &data)
Set the content of the Any to the given value.
Definition: Any.h:151
Gorgon::Scripting::Data::operator=
Data & operator=(Data)
Assignment operator.
Definition: Data.cpp:96
Gorgon::Resource::Data::Append
std::enable_if< std::is_base_of< Base, T_ >::value, void >::type Append(const std::string &name, T_ &value)
Appends the given resource object to the end of this data resource with the specified name.
Definition: Data.h:135
Gorgon::Resource::Data::Data
Data(const T_ &values, const R_ &reflectionobj=T_::Reflection())
This constructor accepts a reflected struct and turns it into a resource data.
Definition: Data.h:70
Gorgon::Resource::Data::Insert
void Insert(const std::string &name, Geometry::Bounds value, int before)
Inserts a data item to the given position with the specified name.
Definition: Data.h:225
Gorgon::Resource::Data::Data
Data()
Creates an empty Data.
Definition: Data.h:64
Gorgon::TMP::RTTI::Name
std::string Name() const
Returns human readable name of the type.
Definition: TMP.h:184
Gorgon::Scripting::Data::parent
Data * parent
Definition: Data.h:196
Gorgon::Resource::Data::Insert
void Insert(const std::string &name, Geometry::Rectangle value, int before)
Inserts a data item to the given position with the specified name.
Definition: Data.h:215
Gorgon::TMP::RTTH::ConstType
RTTS & ConstType
Definition: TMP.h:375
Gorgon::Resource::Data::Insert
void Insert(Geometry::Bounds value, int before)
Inserts a data item to the given position.
Definition: Data.h:220
Gorgon::Resource::PointData
Definition: DataItems.h:156
Gorgon::Resource::Data::begin
Iterator begin()
Can be used to iterate over data objects.
Definition: Data.h:329
Gorgon::Resource::Data::Release
DataItem & Release(const std::string &name)
Releases the data item with the given name. The data item will not be destroyed.
Definition: Data.h:395
Gorgon::GL::UBOBindingPoint::Type
Type
Definition: Shader.h:14
Gorgon::Any::Pointer
void * Pointer() const
Returns the pointer without type information.
Definition: Any.h:332
Gorgon::Resource::Data::Get
T_ Get(int index) const
Returns the data with the given index; use GetObject in order to get resource objects.
Definition: Data.h:294
Data.h
Gorgon::Scripting::Reflection
Library Reflection
Definition: Builtin.cpp:17
Gorgon::Scripting::Data::type
const Type * type
Type of the data.
Definition: Data.h:188
Gorgon::Resource::Data
Definition: Data.h:14
Exceptions.h
Exceptions This file contains string related exceptions.
Gorgon::Resource::GID::Type
Type to store GID information.
Definition: GID.h:23
Gorgon::Geometry::basic_Margin
This class defines Margin of an object or an area.
Definition: Margin.h:22
Gorgon::Resource::Data::Remove
void Remove(int index)
Removes the item at the given index. The data item will be destroyed.
Definition: Data.h:370
Gorgon::TMP::RTTH::PtrType
RTTS & PtrType
Definition: TMP.h:375
Gorgon::Scripting::ReferenceCounter::Decrease
void Decrease(const Data &data)
Decreases the reference count of the given object.
Definition: Runtime.h:68
Gorgon::Resource::Data::GetObject
T_ & GetObject(const std::string &name) const
Returns the resource object with the given name.
Definition: Data.h:314
Gorgon::Resource::Data::Insert
void Insert(float value, int before)
Inserts a data item to the given position.
Definition: Data.h:150
Gorgon::Resource::Data::Remove
void Remove(const std::string &name)
Removes the item with the given name. The data item will be destroyed.
Definition: Data.h:375
Gorgon::Resource::Data::GetCount
int GetCount() const
Returns the number data items in this data resource.
Definition: Data.h:365
Gorgon::Resource::BoundsData
Definition: DataItems.h:266
Gorgon::Geometry::basic_Rectangle
Represents a rectangle in a 2D space.
Definition: Rectangle.h:19
Gorgon::Any::IsSet
bool IsSet() const
Checks whether the Any is set.
Definition: Any.h:398
Gorgon::Any::GetTypeName
std::string GetTypeName() const
Definition: Any.h:272
Gorgon::Resource::Data::GetObject
T_ & GetObject(int index) const
Returns the resource object at the given index.
Definition: Data.h:306
Gorgon::Resource::Data::Get
T_ Get(const std::string &name) const
Returns the data with the given name; use GetObject in order to get resource objects.
Definition: Data.h:300
Gorgon::Resource::DataItem::Get
T_ Get() const
Returns the contents of this data item to the requested type; use GetObject in order to get resource ...
Definition: DataItems.h:40
Gorgon::Scripting::ReferenceCounter::Increase
void Increase(const Data &data)
Increases the reference count of the given object. If it is not registered, this request is ignored.
Definition: Runtime.h:47
Gorgon::Resource::Data::Insert
void Insert(const std::string &name, Base &value, int before)
Inserts a data item to the given position with the specified name.
Definition: Data.h:254
Gorgon::Scripting::Data::isconstant
bool isconstant
This data is a constant and should not be changed.
Definition: Data.h:194
Gorgon::Utils::NotImplemented
void NotImplemented(const std::string &what="This feature")
Definition: Assert.h:187
Gorgon::Resource::Data::Append
std::enable_if< R_::IsGorgonReflection, void >::type Append(const T_ &values, const std::string &prefix, const R_ &reflectionobj=T_::Reflection())
This function accepts a reflected struct and appends it to the resource data.
Definition: Data.h:105
Gorgon::Resource::Data::Insert
void Insert(const std::string &value, int before)
Inserts a data item to the given position.
Definition: Data.h:160
Gorgon::Scripting::Member::GetName
std::string GetName() const
Returns the name of this member.
Definition: Reflection.h:325
DataItems.h