Populous: The Beginning Script 3  1.0.0
Documentation for Populous Script 3 engine
ObjectProxy.h
Go to the documentation of this file.
1 #pragma once
2 
4 {
5 public:
6  ObjectProxy();
7  ObjectProxy(Thing * t);
8  ObjectProxy(const ObjectProxy & me);
9  ObjectProxy(const ThingNum & tnum);
10  ~ObjectProxy();
11 
12  void set(Thing * refT);
13  void set(ThingNum tnum);
14  Thing* get() const;
15  bool isNull() const;
16  ThingNum getThingNum() const;
17 
18  const UBYTE & getType() const;
19  const UBYTE & getFlags() const;
20  void setFlags(const UBYTE & f);
21  void setFlag(const UBYTE & f);
22  void unsetFlag(const UBYTE & f);
23 
24  bool is_type(const UBYTE & t) const;
25  bool is_flag_enabled(const UBYTE & f) const;
26 
27 
28  // Only the objects class should clear references, outside use set(THING_NULL) to properly remove
29  // A reference.
30  void clear();
31 
32  template <class Archive>
33  void save(Archive& ar) const
34  {
35  ThingNum tnum = t_thing ? t_thing->ThingNum : 0;
36  if (tnum)
37  ASSERT(t_thing->Type);
38 
39  ar(POP3SAVENAME(Header), POP3SAVENAME(tnum));
40  }
41 
42  template <class Archive>
43  void load(Archive& ar)
44  {
45  ThingNum ThingID;
46  ar(POP3SAVENAME(Header), POP3SAVENAME(ThingID));
47  if (ThingID > 0)
48  {
49  if (!gsi.ObjectMan.isLoadingCritical())
50  {
51  t_thing = gsi.ObjectMan.getThingWhileLoading(ThingID);
52  ASSERT(t_thing->Type);
53  if (t_thing)
54  gsi.ObjectMan.addReference(this);
55  }
56  else
57  {
58  t_thing = nullptr;
59  gsi.ObjectMan.addMeToQueue(this, ThingID);
60  }
61  }
62 
63  else t_thing = nullptr;
64  }
65  ObjectProxy& operator=(const ThingNum& other);
66  ObjectProxy& operator=(const ObjectProxy& other);
67 
68  bool operator==(const ObjectProxy& b) const;
69  bool operator==(const ThingNum& b) const;
70  bool operator==(const int& b) const;
71  bool operator==(const Thing* b) const;
72 
73  bool operator<(const ObjectProxy& b) const;
74  bool operator<(const ThingNum& b) const;
75  bool operator<(const int& b) const;
76  bool operator<(const Thing* b) const;
77 
78  bool operator<=(const ObjectProxy& b) const;
79  bool operator<=(const ThingNum& b) const;
80  bool operator<=(const int& b) const;
81  bool operator<=(const Thing* b) const;
82 
83  bool operator>(const ObjectProxy& b) const;
84  bool operator>(const ThingNum& b) const;
85  bool operator>(const int& b) const;
86  bool operator>(const Thing* b) const;
87 
88  bool operator>=(const ObjectProxy& b) const;
89  bool operator>=(const ThingNum& b) const;
90  bool operator>=(const int& b) const;
91  bool operator>=(const Thing* b) const;
92 
93  bool operator!=(const ObjectProxy& b) const;
94  bool operator!=(const ThingNum& b) const;
95  bool operator!=(const int& b) const;
96  bool operator!=(const Thing * b) const;
97 
98 
99  Thing* operator->() const;
100  Thing* operator* () const;
101 
102  explicit operator bool() const
103  {
104  return t_thing != nullptr;
105  }
106 private:
108  {
109  UWORD data;
110  struct
111  {
112  UBYTE Type;
113  UBYTE Flags;
114  };
115  template <class Archive>
116  void serialize(Archive& ar)
117  {
118  ar(POP3SAVENAME(data));
119  }
120  };
123 };
124 extern bool operator!=(const ThingNum& lhs, const ObjectProxy& rhs);
125 extern bool operator!=(const int& lhs, const ObjectProxy& rhs);
126 extern bool operator!=(const Thing* lhs, const ObjectProxy& rhs);
127 extern bool operator==(const ThingNum& lhs, const ObjectProxy& rhs);
128 extern bool operator==(const int& lhs, const ObjectProxy& rhs);
129 extern bool operator==(const Thing* lhs, const ObjectProxy& rhs);
bool operator!=(const ObjectProxy &b) const
bool operator<(const ObjectProxy &b) const
void load(Archive &ar)
Definition: ObjectProxy.h:43
Thing * t_thing
Definition: ObjectProxy.h:122
_U_OBJ_LIST Header
Definition: ObjectProxy.h:121
Thing * get() const
void setFlags(const UBYTE &f)
unsigned char Type
ObjectProxy & operator=(const ThingNum &other)
bool operator!=(const ThingNum &lhs, const ObjectProxy &rhs)
void unsetFlag(const UBYTE &f)
unsigned short ThingNum
bool is_type(const UBYTE &t) const
void save(Archive &ar) const
Definition: ObjectProxy.h:33
bool operator==(const ThingNum &lhs, const ObjectProxy &rhs)
bool operator>(const ObjectProxy &b) const
GlobalSaveItems gsi
bool operator<=(const ObjectProxy &b) const
Thing * operator *() const
const UBYTE & getFlags() const
void clear()
ThingNum getThingNum() const
void setFlag(const UBYTE &f)
void serialize(Archive &ar)
Definition: ObjectProxy.h:116
const UBYTE & getType() const
Thing * operator->() const
void set(Thing *refT)
bool is_flag_enabled(const UBYTE &f) const
bool isNull() const
bool operator==(const ObjectProxy &b) const
bool operator>=(const ObjectProxy &b) const