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 // Automatically generated using gen_cpp.py. 6 7 #ifndef ATLAS_OBJECTS_OPERATION_ROOTOPERATION_H 8 #define ATLAS_OBJECTS_OPERATION_ROOTOPERATION_H 9 10 #include <Atlas/Objects/Root.h> 11 #include <Atlas/Objects/SmartPtr.h> 12 13 #include <Atlas/Objects/objectFactory.h> 14 15 namespace Atlas { namespace Objects { namespace Operation { 16 17 /** Base operation for all operators 18 19 This is base operation for all other 20 operations and defines basic attributes. You can use this as 21 starting point for browsing whole operation hiearchy. refno refers 22 to operation this is reply for. In examples all attributes that 23 are just as examples (and thus world specific) are started with 'e_'. 24 25 */ 26 27 class RootOperationData; 28 typedef SmartPtr<RootOperationData> RootOperation; 29 30 static const int ROOT_OPERATION_NO = 9; 31 32 /// \brief Base operation for all operators. 33 /// 34 /** This is base operation for all other 35 operations and defines basic attributes. You can use this as 36 starting point for browsing whole operation hiearchy. refno refers 37 to operation this is reply for. In examples all attributes that 38 are just as examples (and thus world specific) are started with 'e_'. 39 */ 40 class RootOperationData : public RootData 41 { 42 protected: 43 /// Construct a RootOperationData class definition. 44 RootOperationData(RootOperationData *defaults = NULL) : 45 RootData((RootData*)defaults) 46 { 47 m_class_no = ROOT_OPERATION_NO; 48 } 49 /// Default destructor. 50 virtual ~RootOperationData(); 51 52 public: 53 /// Copy this object. 54 virtual RootOperationData * copy() const; 55 56 /// Is this instance of some class? 57 virtual bool instanceOf(int classNo) const; 58 59 /// Retrieve the attribute "name". Return non-zero if it does 60 /// not exist. 61 virtual int copyAttr(const std::string& name, Atlas::Message::Element & attr) const; 62 /// Set the attribute "name" to the value given by"attr" 63 virtual void setAttr(const std::string& name, 64 const Atlas::Message::Element& attr); 65 /// Remove the attribute "name". This will not work for static attributes. 66 virtual void removeAttr(const std::string& name); 67 68 /// Send the contents of this object to a Bridge. 69 virtual void sendContents(Atlas::Bridge & b) const; 70 71 /// Write this object to an existing Element. 72 virtual void addToMessage(Atlas::Message::MapType &) const; 73 74 /// Set the "serialno" attribute. 75 inline void setSerialno(long val); 76 /// Set the "refno" attribute. 77 inline void setRefno(long val); 78 /// Set the "from" attribute. 79 inline void setFrom(const std::string& val); 80 /// Set the "to" attribute. 81 inline void setTo(const std::string& val); 82 /// Set the "seconds" attribute. 83 inline void setSeconds(double val); 84 /// Set the "future_seconds" attribute. 85 inline void setFutureSeconds(double val); 86 /// Set the "args" attribute. 87 inline void setArgs(const std::vector<Root>& val); 88 /// Set the "args" attribute AsList. 89 inline void setArgsAsList(const Atlas::Message::ListType& val); 90 /// Set the first member of "args" 91 template <class ObjectData> 92 inline void setArgs1(const SmartPtr<ObjectData> & val); 93 94 /// Retrieve the "serialno" attribute. 95 inline long getSerialno() const; 96 /// Retrieve the "serialno" attribute as a non-const reference. 97 inline long& modifySerialno(); 98 /// Retrieve the "refno" attribute. 99 inline long getRefno() const; 100 /// Retrieve the "refno" attribute as a non-const reference. 101 inline long& modifyRefno(); 102 /// Retrieve the "from" attribute. 103 inline const std::string& getFrom() const; 104 /// Retrieve the "from" attribute as a non-const reference. 105 inline std::string& modifyFrom(); 106 /// Retrieve the "to" attribute. 107 inline const std::string& getTo() const; 108 /// Retrieve the "to" attribute as a non-const reference. 109 inline std::string& modifyTo(); 110 /// Retrieve the "seconds" attribute. 111 inline double getSeconds() const; 112 /// Retrieve the "seconds" attribute as a non-const reference. 113 inline double& modifySeconds(); 114 /// Retrieve the "future_seconds" attribute. 115 inline double getFutureSeconds() const; 116 /// Retrieve the "future_seconds" attribute as a non-const reference. 117 inline double& modifyFutureSeconds(); 118 /// Retrieve the "args" attribute. 119 inline const std::vector<Root>& getArgs() const; 120 /// Retrieve the "args" attribute as a non-const reference. 121 inline std::vector<Root>& modifyArgs(); 122 /// Retrieve the "args" attribute AsList. 123 inline const Atlas::Message::ListType getArgsAsList() const; 124 125 /// Is "serialno" value default? 126 inline bool isDefaultSerialno() const; 127 /// Is "refno" value default? 128 inline bool isDefaultRefno() const; 129 /// Is "from" value default? 130 inline bool isDefaultFrom() const; 131 /// Is "to" value default? 132 inline bool isDefaultTo() const; 133 /// Is "seconds" value default? 134 inline bool isDefaultSeconds() const; 135 /// Is "future_seconds" value default? 136 inline bool isDefaultFutureSeconds() const; 137 /// Is "args" value default? 138 inline bool isDefaultArgs() const; 139 140 protected: 141 /// Find the class which contains the attribute "name". 142 virtual int getAttrClass(const std::string& name)const; 143 /// Find the flag for the attribute "name". 144 virtual int getAttrFlag(const std::string& name)const; 145 /// Serial number. 146 long attr_serialno; 147 /// Reference to serial number. 148 long attr_refno; 149 /// Source of message/operation. 150 std::string attr_from; 151 /// Target of message/operation. 152 std::string attr_to; 153 /// Time in seconds 154 double attr_seconds; 155 /// Time in seconds to add current time 156 double attr_future_seconds; 157 /// List of arguments this operation has 158 std::vector<Root> attr_args; 159 160 /// Send the "serialno" attribute to an Atlas::Bridge. 161 void sendSerialno(Atlas::Bridge&) const; 162 /// Send the "refno" attribute to an Atlas::Bridge. 163 void sendRefno(Atlas::Bridge&) const; 164 /// Send the "from" attribute to an Atlas::Bridge. 165 void sendFrom(Atlas::Bridge&) const; 166 /// Send the "to" attribute to an Atlas::Bridge. 167 void sendTo(Atlas::Bridge&) const; 168 /// Send the "seconds" attribute to an Atlas::Bridge. 169 void sendSeconds(Atlas::Bridge&) const; 170 /// Send the "future_seconds" attribute to an Atlas::Bridge. 171 void sendFutureSeconds(Atlas::Bridge&) const; 172 /// Send the "args" attribute to an Atlas::Bridge. 173 void sendArgs(Atlas::Bridge&) const; 174 175 virtual void iterate(int& current_class, std::string& attr) const; 176 177 //freelist related things 178 public: 179 static RootOperationData *alloc(); 180 virtual void free(); 181 182 /// \brief Get the reference object that contains the default values for 183 /// attributes of instances of the same class as this object. 184 /// 185 /// @return a pointer to the default object. 186 virtual RootOperationData *getDefaultObject(); 187 188 /// \brief Get the reference object that contains the default values for 189 /// attributes of instances of this class. 190 /// 191 /// @return a pointer to the default object. 192 static RootOperationData *getDefaultObjectInstance(); 193 private: 194 static RootOperationData *defaults_RootOperationData; 195 static RootOperationData *begin_RootOperationData; 196 197 static std::map<std::string, int> * attr_flags_RootOperationData; 198 }; 199 200 // 201 // Attribute name strings follow. 202 // 203 204 extern const std::string SERIALNO_ATTR; 205 extern const std::string REFNO_ATTR; 206 extern const std::string FROM_ATTR; 207 extern const std::string TO_ATTR; 208 extern const std::string SECONDS_ATTR; 209 extern const std::string FUTURE_SECONDS_ATTR; 210 extern const std::string ARGS_ATTR; 211 212 // 213 // Inlined member functions follow. 214 // 215 216 const int SERIALNO_FLAG = 1 << 14; 217 setSerialno(long val)218void RootOperationData::setSerialno(long val) 219 { 220 attr_serialno = val; 221 m_attrFlags |= SERIALNO_FLAG; 222 } 223 224 const int REFNO_FLAG = 1 << 15; 225 setRefno(long val)226void RootOperationData::setRefno(long val) 227 { 228 attr_refno = val; 229 m_attrFlags |= REFNO_FLAG; 230 } 231 232 const int FROM_FLAG = 1 << 16; 233 setFrom(const std::string & val)234void RootOperationData::setFrom(const std::string& val) 235 { 236 attr_from = val; 237 m_attrFlags |= FROM_FLAG; 238 } 239 240 const int TO_FLAG = 1 << 17; 241 setTo(const std::string & val)242void RootOperationData::setTo(const std::string& val) 243 { 244 attr_to = val; 245 m_attrFlags |= TO_FLAG; 246 } 247 248 const int SECONDS_FLAG = 1 << 18; 249 setSeconds(double val)250void RootOperationData::setSeconds(double val) 251 { 252 attr_seconds = val; 253 m_attrFlags |= SECONDS_FLAG; 254 } 255 256 const int FUTURE_SECONDS_FLAG = 1 << 19; 257 setFutureSeconds(double val)258void RootOperationData::setFutureSeconds(double val) 259 { 260 attr_future_seconds = val; 261 m_attrFlags |= FUTURE_SECONDS_FLAG; 262 } 263 264 const int ARGS_FLAG = 1 << 20; 265 setArgs(const std::vector<Root> & val)266void RootOperationData::setArgs(const std::vector<Root>& val) 267 { 268 attr_args = val; 269 m_attrFlags |= ARGS_FLAG; 270 } 271 setArgsAsList(const Atlas::Message::ListType & val)272void RootOperationData::setArgsAsList(const Atlas::Message::ListType& val) 273 { 274 m_attrFlags |= ARGS_FLAG; 275 attr_args.resize(0); 276 for(Message::ListType::const_iterator I = val.begin(); 277 I != val.end(); 278 I++) 279 { 280 if (I->isMap()) { 281 attr_args.push_back(Factories::instance()->createObject(I->asMap())); 282 } 283 } 284 } 285 286 template <class ObjectData> setArgs1(const SmartPtr<ObjectData> & val)287void RootOperationData::setArgs1(const SmartPtr<ObjectData>& val) 288 { 289 m_attrFlags |= ARGS_FLAG; 290 if(attr_args.size()!=1) attr_args.resize(1); 291 attr_args[0] = val; 292 } 293 getSerialno()294long RootOperationData::getSerialno() const 295 { 296 if(m_attrFlags & SERIALNO_FLAG) 297 return attr_serialno; 298 else 299 return ((RootOperationData*)m_defaults)->attr_serialno; 300 } 301 modifySerialno()302long& RootOperationData::modifySerialno() 303 { 304 if(!(m_attrFlags & SERIALNO_FLAG)) 305 setSerialno(((RootOperationData*)m_defaults)->attr_serialno); 306 return attr_serialno; 307 } 308 getRefno()309long RootOperationData::getRefno() const 310 { 311 if(m_attrFlags & REFNO_FLAG) 312 return attr_refno; 313 else 314 return ((RootOperationData*)m_defaults)->attr_refno; 315 } 316 modifyRefno()317long& RootOperationData::modifyRefno() 318 { 319 if(!(m_attrFlags & REFNO_FLAG)) 320 setRefno(((RootOperationData*)m_defaults)->attr_refno); 321 return attr_refno; 322 } 323 getFrom()324const std::string& RootOperationData::getFrom() const 325 { 326 if(m_attrFlags & FROM_FLAG) 327 return attr_from; 328 else 329 return ((RootOperationData*)m_defaults)->attr_from; 330 } 331 modifyFrom()332std::string& RootOperationData::modifyFrom() 333 { 334 if(!(m_attrFlags & FROM_FLAG)) 335 setFrom(((RootOperationData*)m_defaults)->attr_from); 336 return attr_from; 337 } 338 getTo()339const std::string& RootOperationData::getTo() const 340 { 341 if(m_attrFlags & TO_FLAG) 342 return attr_to; 343 else 344 return ((RootOperationData*)m_defaults)->attr_to; 345 } 346 modifyTo()347std::string& RootOperationData::modifyTo() 348 { 349 if(!(m_attrFlags & TO_FLAG)) 350 setTo(((RootOperationData*)m_defaults)->attr_to); 351 return attr_to; 352 } 353 getSeconds()354double RootOperationData::getSeconds() const 355 { 356 if(m_attrFlags & SECONDS_FLAG) 357 return attr_seconds; 358 else 359 return ((RootOperationData*)m_defaults)->attr_seconds; 360 } 361 modifySeconds()362double& RootOperationData::modifySeconds() 363 { 364 if(!(m_attrFlags & SECONDS_FLAG)) 365 setSeconds(((RootOperationData*)m_defaults)->attr_seconds); 366 return attr_seconds; 367 } 368 getFutureSeconds()369double RootOperationData::getFutureSeconds() const 370 { 371 if(m_attrFlags & FUTURE_SECONDS_FLAG) 372 return attr_future_seconds; 373 else 374 return ((RootOperationData*)m_defaults)->attr_future_seconds; 375 } 376 modifyFutureSeconds()377double& RootOperationData::modifyFutureSeconds() 378 { 379 if(!(m_attrFlags & FUTURE_SECONDS_FLAG)) 380 setFutureSeconds(((RootOperationData*)m_defaults)->attr_future_seconds); 381 return attr_future_seconds; 382 } 383 getArgs()384const std::vector<Root>& RootOperationData::getArgs() const 385 { 386 if(m_attrFlags & ARGS_FLAG) 387 return attr_args; 388 else 389 return ((RootOperationData*)m_defaults)->attr_args; 390 } 391 modifyArgs()392std::vector<Root>& RootOperationData::modifyArgs() 393 { 394 if(!(m_attrFlags & ARGS_FLAG)) 395 setArgs(((RootOperationData*)m_defaults)->attr_args); 396 return attr_args; 397 } 398 getArgsAsList()399const Atlas::Message::ListType RootOperationData::getArgsAsList() const 400 { 401 const std::vector<Root>& args_in = getArgs(); 402 Atlas::Message::ListType args_out; 403 for(std::vector<Root>::const_iterator I = args_in.begin(); 404 I != args_in.end(); 405 I++) 406 { 407 args_out.push_back(Atlas::Message::MapType()); 408 (*I)->addToMessage(args_out.back().asMap()); 409 } 410 return args_out; 411 } 412 isDefaultSerialno()413bool RootOperationData::isDefaultSerialno() const 414 { 415 return (m_attrFlags & SERIALNO_FLAG) == 0; 416 } 417 isDefaultRefno()418bool RootOperationData::isDefaultRefno() const 419 { 420 return (m_attrFlags & REFNO_FLAG) == 0; 421 } 422 isDefaultFrom()423bool RootOperationData::isDefaultFrom() const 424 { 425 return (m_attrFlags & FROM_FLAG) == 0; 426 } 427 isDefaultTo()428bool RootOperationData::isDefaultTo() const 429 { 430 return (m_attrFlags & TO_FLAG) == 0; 431 } 432 isDefaultSeconds()433bool RootOperationData::isDefaultSeconds() const 434 { 435 return (m_attrFlags & SECONDS_FLAG) == 0; 436 } 437 isDefaultFutureSeconds()438bool RootOperationData::isDefaultFutureSeconds() const 439 { 440 return (m_attrFlags & FUTURE_SECONDS_FLAG) == 0; 441 } 442 isDefaultArgs()443bool RootOperationData::isDefaultArgs() const 444 { 445 return (m_attrFlags & ARGS_FLAG) == 0; 446 } 447 448 449 } } } // namespace Atlas::Objects::Operation 450 451 #endif // ATLAS_OBJECTS_OPERATION_ROOTOPERATION_H 452