Atlas  0.7.0
Networking protocol for the Worldforge system.
RootOperation.h
1 // This file may be redistributed and modified only under the terms of
2 // the GNU Lesser General Public License (See COPYING for details).
3 // Copyright 2000-2001 Stefanus Du Toit and Aloril.
4 // Copyright 2001-2005 Alistair Riddoch.
5 // Copyright 2011-2020 Erik Ogenvik.
6 // Automatically generated using gen_cpp.py. Don't edit directly.
7 
8 #ifndef ATLAS_OBJECTS_OPERATION_ROOTOPERATION_H
9 #define ATLAS_OBJECTS_OPERATION_ROOTOPERATION_H
10 
11 #include <Atlas/Objects/Root.h>
12 #include <Atlas/Objects/SmartPtr.h>
13 
14 #include <Atlas/Objects/Factories.h>
15 
16 namespace Atlas { namespace Objects { namespace Operation {
17 
28 class RootOperationData;
29 typedef SmartPtr<RootOperationData> RootOperation;
30 
31 static const int ROOT_OPERATION_NO = 9;
32 
35 
42 {
43 protected:
45  explicit RootOperationData(RootOperationData *defaults = nullptr) :
46  RootData((RootData*)defaults)
47  {
48  m_class_no = ROOT_OPERATION_NO;
49  }
51  ~RootOperationData() override = default;
52 
53 public:
54  // The parent type for this object's superclass
55  static constexpr const char* super_parent = "root";
56  // The default parent type for this object
57  static constexpr const char* default_parent = "root_operation";
58  // The default objtype for this object
59  static constexpr const char* default_objtype = "op";
61  RootOperationData * copy() const override;
62 
64  bool instanceOf(int classNo) const override;
65 
68  int copyAttr(const std::string& name, Atlas::Message::Element & attr) const override;
70  void setAttr(std::string name,
71  Atlas::Message::Element attr, const Atlas::Objects::Factories* factories = nullptr) override;
73  void removeAttr(const std::string& name) override;
74 
76  void sendContents(Atlas::Bridge & b) const override;
77 
79  void addToMessage(Atlas::Message::MapType &) const override;
80 
82  void setSerialno(std::int64_t val);
84  void setRefno(std::int64_t val);
86  void setFrom(std::string val);
88  void setTo(std::string val);
90  void setSeconds(double val);
92  void setFutureSeconds(double val);
94  void setArgs(std::vector<Root> val);
96  void setArgsAsList(const Atlas::Message::ListType& val, const Atlas::Objects::Factories* factories);
98  void setArgsAsList(Atlas::Message::ListType&& val, const Atlas::Objects::Factories* factories);
100  template <class ObjectData>
101  void setArgs1(SmartPtr<ObjectData> val);
102 
104  std::int64_t getSerialno() const;
106  std::int64_t& modifySerialno();
108  std::int64_t getRefno() const;
110  std::int64_t& modifyRefno();
112  const std::string& getFrom() const;
114  std::string& modifyFrom();
116  const std::string& getTo() const;
118  std::string& modifyTo();
120  double getSeconds() const;
122  double& modifySeconds();
124  double getFutureSeconds() const;
126  double& modifyFutureSeconds();
128  const std::vector<Root>& getArgs() const;
130  std::vector<Root>& modifyArgs();
132  Atlas::Message::ListType getArgsAsList() const;
133 
135  bool isDefaultSerialno() const;
137  bool isDefaultRefno() const;
139  bool isDefaultFrom() const;
141  bool isDefaultTo() const;
143  bool isDefaultSeconds() const;
145  bool isDefaultFutureSeconds() const;
147  bool isDefaultArgs() const;
148 
149 protected:
151  int getAttrClass(const std::string& name)const override;
153  bool getAttrFlag(const std::string& name, uint32_t& flag)const override;
155  std::int64_t attr_serialno;
157  std::int64_t attr_refno;
159  std::string attr_from;
161  std::string attr_to;
163  double attr_seconds;
167  std::vector<Root> attr_args;
168 
170  void sendSerialno(Atlas::Bridge&) const;
172  void sendRefno(Atlas::Bridge&) const;
174  void sendFrom(Atlas::Bridge&) const;
176  void sendTo(Atlas::Bridge&) const;
178  void sendSeconds(Atlas::Bridge&) const;
180  void sendFutureSeconds(Atlas::Bridge&) const;
182  void sendArgs(Atlas::Bridge&) const;
183 
184 public:
185  template <typename>
186  friend class ::Atlas::Objects::Allocator;
187  static Allocator<RootOperationData> allocator;
188 
189 protected:
191  void reset() override;
192  void free() override;
193 
194 private:
195 
196  static void fillDefaultObjectInstance(RootOperationData& data, std::map<std::string, uint32_t>& attr_data);
197 };
198 
199 //
200 // Attribute name strings follow.
201 //
202 
203 extern const std::string SERIALNO_ATTR;
204 extern const std::string REFNO_ATTR;
205 extern const std::string FROM_ATTR;
206 extern const std::string TO_ATTR;
207 extern const std::string SECONDS_ATTR;
208 extern const std::string FUTURE_SECONDS_ATTR;
209 extern const std::string ARGS_ATTR;
210 
211 //
212 // Inlined member functions follow.
213 //
214 
215 const uint32_t SERIALNO_FLAG = 1u << 14u;
216 
217 inline void RootOperationData::setSerialno(std::int64_t val)
218 {
219  attr_serialno = val;
220  m_attrFlags |= SERIALNO_FLAG;
221 }
222 
223 const uint32_t REFNO_FLAG = 1u << 15u;
224 
225 inline void RootOperationData::setRefno(std::int64_t val)
226 {
227  attr_refno = val;
228  m_attrFlags |= REFNO_FLAG;
229 }
230 
231 const uint32_t FROM_FLAG = 1u << 16u;
232 
233 inline void RootOperationData::setFrom(std::string val)
234 {
235  attr_from = std::move(val);
236  m_attrFlags |= FROM_FLAG;
237 }
238 
239 const uint32_t TO_FLAG = 1u << 17u;
240 
241 inline void RootOperationData::setTo(std::string val)
242 {
243  attr_to = std::move(val);
244  m_attrFlags |= TO_FLAG;
245 }
246 
247 const uint32_t SECONDS_FLAG = 1u << 18u;
248 
249 inline void RootOperationData::setSeconds(double val)
250 {
251  attr_seconds = val;
252  m_attrFlags |= SECONDS_FLAG;
253 }
254 
255 const uint32_t FUTURE_SECONDS_FLAG = 1u << 19u;
256 
257 inline void RootOperationData::setFutureSeconds(double val)
258 {
259  attr_future_seconds = val;
260  m_attrFlags |= FUTURE_SECONDS_FLAG;
261 }
262 
263 const uint32_t ARGS_FLAG = 1u << 20u;
264 
265 inline void RootOperationData::setArgs(std::vector<Root> val)
266 {
267  attr_args = std::move(val);
268  m_attrFlags |= ARGS_FLAG;
269 }
270 
271 inline void RootOperationData::setArgsAsList(const Atlas::Message::ListType& val, const Factories* factories)
272 {
273  if (!factories) {
274  throw Exception("You must pass in a valid Factories instance when setting 'args'.");
275  }
276  m_attrFlags |= ARGS_FLAG;
277  attr_args = factories->parseListOfObjects(val);
278 }
279 
280 inline void RootOperationData::setArgsAsList(Atlas::Message::ListType&& val, const Factories* factories)
281 {
282  if (!factories) {
283  throw Exception("You must pass in a valid Factories instance when setting 'args'.");
284  }
285  m_attrFlags |= ARGS_FLAG;
286  attr_args = factories->parseListOfObjects(std::move(val));
287 }
288 
289 template <class ObjectData>
291 {
292  m_attrFlags |= ARGS_FLAG;
293  if(attr_args.size()!=1) attr_args.resize(1);
294  attr_args[0] = std::move(val);
295 }
296 
297 inline std::int64_t RootOperationData::getSerialno() const
298 {
299  if(m_attrFlags & SERIALNO_FLAG)
300  return attr_serialno;
301  else
302  return ((RootOperationData*)m_defaults)->attr_serialno;
303 }
304 
305 inline std::int64_t& RootOperationData::modifySerialno()
306 {
307  if(!(m_attrFlags & SERIALNO_FLAG))
309  return attr_serialno;
310 }
311 
312 inline std::int64_t RootOperationData::getRefno() const
313 {
314  if(m_attrFlags & REFNO_FLAG)
315  return attr_refno;
316  else
317  return ((RootOperationData*)m_defaults)->attr_refno;
318 }
319 
320 inline std::int64_t& RootOperationData::modifyRefno()
321 {
322  if(!(m_attrFlags & REFNO_FLAG))
324  return attr_refno;
325 }
326 
327 inline const std::string& RootOperationData::getFrom() const
328 {
329  if(m_attrFlags & FROM_FLAG)
330  return attr_from;
331  else
332  return ((RootOperationData*)m_defaults)->attr_from;
333 }
334 
335 inline std::string& RootOperationData::modifyFrom()
336 {
337  if(!(m_attrFlags & FROM_FLAG))
339  return attr_from;
340 }
341 
342 inline const std::string& RootOperationData::getTo() const
343 {
344  if(m_attrFlags & TO_FLAG)
345  return attr_to;
346  else
347  return ((RootOperationData*)m_defaults)->attr_to;
348 }
349 
350 inline std::string& RootOperationData::modifyTo()
351 {
352  if(!(m_attrFlags & TO_FLAG))
354  return attr_to;
355 }
356 
357 inline double RootOperationData::getSeconds() const
358 {
359  if(m_attrFlags & SECONDS_FLAG)
360  return attr_seconds;
361  else
362  return ((RootOperationData*)m_defaults)->attr_seconds;
363 }
364 
366 {
367  if(!(m_attrFlags & SECONDS_FLAG))
369  return attr_seconds;
370 }
371 
373 {
374  if(m_attrFlags & FUTURE_SECONDS_FLAG)
375  return attr_future_seconds;
376  else
377  return ((RootOperationData*)m_defaults)->attr_future_seconds;
378 }
379 
381 {
382  if(!(m_attrFlags & FUTURE_SECONDS_FLAG))
384  return attr_future_seconds;
385 }
386 
387 inline const std::vector<Root>& RootOperationData::getArgs() const
388 {
389  if(m_attrFlags & ARGS_FLAG)
390  return attr_args;
391  else
392  return ((RootOperationData*)m_defaults)->attr_args;
393 }
394 
395 inline std::vector<Root>& RootOperationData::modifyArgs()
396 {
397  if(!(m_attrFlags & ARGS_FLAG))
399  return attr_args;
400 }
401 
402 inline Atlas::Message::ListType RootOperationData::getArgsAsList() const
403 {
404  const std::vector<Root>& args_in = getArgs();
405  Atlas::Message::ListType args_out;
406  for (const auto& entry : args_in) {
407  args_out.push_back(Atlas::Message::MapType());
408  entry->addToMessage(args_out.back().Map());
409  }
410  return args_out;
411 }
412 
414 {
415  return (m_attrFlags & SERIALNO_FLAG) == 0;
416 }
417 
419 {
420  return (m_attrFlags & REFNO_FLAG) == 0;
421 }
422 
424 {
425  return (m_attrFlags & FROM_FLAG) == 0;
426 }
427 
429 {
430  return (m_attrFlags & TO_FLAG) == 0;
431 }
432 
434 {
435  return (m_attrFlags & SECONDS_FLAG) == 0;
436 }
437 
439 {
440  return (m_attrFlags & FUTURE_SECONDS_FLAG) == 0;
441 }
442 
444 {
445  return (m_attrFlags & ARGS_FLAG) == 0;
446 }
447 
448 
449 } } } // namespace Atlas::Objects::Operation
450 
451 #endif // ATLAS_OBJECTS_OPERATION_ROOTOPERATION_H
BaseObjectData * m_defaults
Definition: BaseObject.h:330
std::vector< Root > parseListOfObjects(const Atlas::Message::ListType &val) const
Definition: Factories.cpp:151
Base operation for all operators.
Definition: RootOperation.h:42
void setFrom(std::string val)
Set the "from" attribute.
bool isDefaultTo() const
Is "to" value default?
bool isDefaultArgs() const
Is "args" value default?
void setTo(std::string val)
Set the "to" attribute.
std::string attr_from
Source of message/operation.
double & modifyFutureSeconds()
Retrieve the "future_seconds" attribute as a non-const reference.
int copyAttr(const std::string &name, Atlas::Message::Element &attr) const override
bool instanceOf(int classNo) const override
Is this instance of some class?
const std::string & getFrom() const
Retrieve the "from" attribute.
std::vector< Root > attr_args
List of arguments this operation has.
void sendFutureSeconds(Atlas::Bridge &) const
Send the "future_seconds" attribute to an Atlas::Bridge.
std::int64_t getRefno() const
Retrieve the "refno" attribute.
void sendTo(Atlas::Bridge &) const
Send the "to" attribute to an Atlas::Bridge.
std::string & modifyTo()
Retrieve the "to" attribute as a non-const reference.
bool getAttrFlag(const std::string &name, uint32_t &flag) const override
Find the flag for the attribute "name".
double getSeconds() const
Retrieve the "seconds" attribute.
const std::string & getTo() const
Retrieve the "to" attribute.
bool isDefaultFutureSeconds() const
Is "future_seconds" value default?
void setSerialno(std::int64_t val)
Set the "serialno" attribute.
~RootOperationData() override=default
Default destructor.
bool isDefaultSerialno() const
Is "serialno" value default?
Atlas::Message::ListType getArgsAsList() const
Retrieve the "args" attribute AsList.
double attr_future_seconds
Time in seconds to add current time.
void free() override
Free an instance of this class, returning it to the memory pool.
int getAttrClass(const std::string &name) const override
Find the class which contains the attribute "name".
std::vector< Root > & modifyArgs()
Retrieve the "args" attribute as a non-const reference.
void sendFrom(Atlas::Bridge &) const
Send the "from" attribute to an Atlas::Bridge.
RootOperationData * copy() const override
Copy this object.
void setSeconds(double val)
Set the "seconds" attribute.
std::string & modifyFrom()
Retrieve the "from" attribute as a non-const reference.
void setRefno(std::int64_t val)
Set the "refno" attribute.
void setArgs1(SmartPtr< ObjectData > val)
Set the first member of "args".
void sendContents(Atlas::Bridge &b) const override
Send the contents of this object to a Bridge.
void sendSerialno(Atlas::Bridge &) const
Send the "serialno" attribute to an Atlas::Bridge.
double & modifySeconds()
Retrieve the "seconds" attribute as a non-const reference.
void setFutureSeconds(double val)
Set the "future_seconds" attribute.
void sendRefno(Atlas::Bridge &) const
Send the "refno" attribute to an Atlas::Bridge.
void reset() override
Resets the object as it's returned to the pool.
std::int64_t & modifyRefno()
Retrieve the "refno" attribute as a non-const reference.
void removeAttr(const std::string &name) override
Remove the attribute "name". This will not work for static attributes.
double getFutureSeconds() const
Retrieve the "future_seconds" attribute.
RootOperationData(RootOperationData *defaults=nullptr)
Construct a RootOperationData class definition.
Definition: RootOperation.h:45
std::int64_t attr_refno
Reference to serial number.
void setAttr(std::string name, Atlas::Message::Element attr, const Atlas::Objects::Factories *factories=nullptr) override
Set the attribute "name" to the value given by"attr".
std::string attr_to
Target of message/operation.
void setArgsAsList(const Atlas::Message::ListType &val, const Atlas::Objects::Factories *factories)
Set the "args" attribute AsList.
std::int64_t getSerialno() const
Retrieve the "serialno" attribute.
bool isDefaultRefno() const
Is "refno" value default?
bool isDefaultFrom() const
Is "from" value default?
void addToMessage(Atlas::Message::MapType &) const override
Write this object to an existing Element.
void sendArgs(Atlas::Bridge &) const
Send the "args" attribute to an Atlas::Bridge.
std::int64_t & modifySerialno()
Retrieve the "serialno" attribute as a non-const reference.
const std::vector< Root > & getArgs() const
Retrieve the "args" attribute.
bool isDefaultSeconds() const
Is "seconds" value default?
void setArgs(std::vector< Root > val)
Set the "args" attribute.
std::int64_t attr_serialno
Serial number.
void sendSeconds(Atlas::Bridge &) const
Send the "seconds" attribute to an Atlas::Bridge.
All objects inherit from this..
Definition: Root.h:37
Definition: Bridge.h:20