lsst.astshim
19.0.0-3-ge74d124
|
Go to the documentation of this file.
22 #ifndef ASTSHIM_OBJECT_H
23 #define ASTSHIM_OBJECT_H
56 using Deleter = void (*)(AstObject *);
59 using ObjectPtr = std::unique_ptr<AstObject, Deleter>;
83 return !(*
this == rhs); };
88 static std::shared_ptr<Object>
fromString(std::string
const &str) {
89 auto *rawPtr =
reinterpret_cast<AstObject *
>(astFromString(str.c_str()));
91 return Object::_basicFromAstObject(rawPtr);
105 template <
typename Class>
119 void clear(std::string
const &attrib) {
128 bool ret = astHasAttribute(
getRawPtr(), attrib.c_str());
203 astLock(
getRawPtr(),
static_cast<int>(wait));
229 void show(std::ostream &os,
bool showComments =
true)
const;
236 std::string
show(
bool showComments =
true)
const;
250 bool test(std::string
const &attrib)
const {
251 bool res = astTest(
getRawPtr(), attrib.c_str());
281 astUnlock(
getRawPtr(),
static_cast<int>(report));
292 AstObject
const *
getRawPtr()
const {
return &*_objPtr; };
301 explicit Object(AstObject *
object);
309 template <
typename ShimT,
typename AstT>
310 static std::shared_ptr<ShimT>
makeShim(AstObject *p) {
311 return std::shared_ptr<ShimT>(
new ShimT(
reinterpret_cast<AstT *
>(p)));
319 template <
typename T,
typename AstT>
321 auto *rawptr =
reinterpret_cast<AstT *
>(astCopy(
getRawPtr()));
322 auto retptr = std::shared_ptr<T>(
new T(rawptr));
348 bool getB(std::string
const &attrib)
const {
349 bool val = astGetI(
getRawPtr(), attrib.c_str());
361 std::string
const getC(std::string
const &attrib)
const {
362 char const *rawval = astGetC(
getRawPtr(), attrib.c_str());
364 return std::string(rawval);
374 double getD(std::string
const &attrib)
const {
375 double val = astGetD(
getRawPtr(), attrib.c_str());
387 float getF(std::string
const &attrib)
const {
388 float val = astGetF(
getRawPtr(), attrib.c_str());
400 int getI(std::string
const &attrib)
const {
401 int val = astGetI(
getRawPtr(), attrib.c_str());
413 long int getL(std::string
const &attrib)
const {
414 long int val = astGetL(
getRawPtr(), attrib.c_str());
440 void set(std::string
const &setting) {
441 astSet(
getRawPtr(),
"%s", setting.c_str());
452 void setB(std::string
const &attrib,
bool value) {
453 astSetI(
getRawPtr(), attrib.c_str(), value);
464 void setC(std::string
const &attrib, std::string
const &value) {
465 astSetC(
getRawPtr(), attrib.c_str(), value.c_str());
476 void setD(std::string
const &attrib,
double value) {
477 astSetD(
getRawPtr(), attrib.c_str(), value);
488 void setF(std::string
const &attrib,
float value) {
489 astSetF(
getRawPtr(), attrib.c_str(), value);
500 void setI(std::string
const &attrib,
int value) {
501 astSetI(
getRawPtr(), attrib.c_str(), value);
512 void setL(std::string
const &attrib,
long int value) {
513 astSetL(
getRawPtr(), attrib.c_str(), value);
525 static std::shared_ptr<Object> _basicFromAstObject(AstObject *rawObj);
530 AstObject * getRawPtrCopy()
const {
531 AstObject * rawPtrCopy =
reinterpret_cast<AstObject *
>(astCopy(
getRawPtr()));
539 void swapRawPointers(
Object &other) noexcept {
540 swap(_objPtr, other._objPtr);
int getNObject() const
Definition: Object.h:153
void annulAstObject(AstObject *object)
A wrapper around astAnnul; intended as a custom deleter for std::unique_ptr.
Definition: utils.h:40
void show(std::ostream &os, bool showComments=true) const
Definition: Object.cc:158
double getD(std::string const &attrib) const
Definition: Object.h:374
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Definition: base.cc:49
bool operator==(Object const &rhs) const
Definition: Object.cc:85
AstObject * getRawPtr()
Definition: Object.h:294
std::string getClassName() const
Definition: Object.h:139
Object & operator=(Object const &)=delete
virtual ~Object()
Definition: Object.h:61
std::string const getC(std::string const &attrib) const
Definition: Object.h:361
void setUseDefs(bool usedefs)
Set UseDefs: allow use of default values for Object attributes?
Definition: Object.h:221
std::unique_ptr< AstObject, Deleter > ObjectPtr
unique pointer holding an AST raw pointer
Definition: Object.h:59
void setI(std::string const &attrib, int value)
Definition: Object.h:500
Object & operator=(Object &&)=default
virtual std::shared_ptr< Object > copyPolymorphic() const =0
AstObject const * getRawPtr() const
Definition: Object.h:292
static std::shared_ptr< Object > fromString(std::string const &str)
Definition: Object.h:88
int getObjSize() const
Get ObjSize: the in-memory size of the AST object in bytes.
Definition: Object.h:156
float getF(std::string const &attrib) const
Definition: Object.h:387
void clear(std::string const &attrib)
Definition: Object.h:119
void setB(std::string const &attrib, bool value)
Definition: Object.h:452
static std::shared_ptr< ShimT > makeShim(AstObject *p)
Definition: Object.h:310
Object(Object &&)=default
void setC(std::string const &attrib, std::string const &value)
Definition: Object.h:464
bool getB(std::string const &attrib) const
Definition: Object.h:348
int getRefCount() const
Definition: Object.h:163
bool getUseDefs() const
Get UseDefs: allow use of default values for Object attributes?
Definition: Object.h:166
Definition: MapSplit.h:38
bool same(Object const &other) const
Definition: Object.h:212
std::string getClassName(AstObject const *rawObj)
Definition: utils.cc:37
void lock(bool wait)
Definition: Object.h:202
void setD(std::string const &attrib, double value)
Definition: Object.h:476
std::string getIdent() const
Get Ident: object identification string that is copied.
Definition: Object.h:145
int getI(std::string const &attrib) const
Definition: Object.h:400
AST wrapper classes and functions.
Definition: attributes_channel.dox:1
bool hasAttribute(std::string const &attrib) const
Definition: Object.h:127
bool test(std::string const &attrib) const
Definition: Object.h:250
void setF(std::string const &attrib, float value)
Definition: Object.h:488
std::shared_ptr< Object > copy() const
Return a deep copy of this object.
Definition: Object.h:109
Definition: FrameDict.h:67
void set(std::string const &setting)
Definition: Object.h:440
std::string getID() const
Get ID: object identification string that is not copied.
Definition: Object.h:142
void setID(std::string const &id)
Set ID: object identification string that is not copied.
Definition: Object.h:215
static std::shared_ptr< Class > fromAstObject(AstObject *rawObj, bool copy)
Definition: Object.cc:138
void setL(std::string const &attrib, long int value)
Definition: Object.h:512
std::shared_ptr< T > copyImpl() const
Definition: Object.h:320
long int getL(std::string const &attrib) const
Definition: Object.h:413
void unlock(bool report=false)
Definition: Object.h:280
Object(Object const &object)
Copy constructor: make a deep copy.
Definition: Object.h:64
bool operator!=(Object const &rhs) const
Definition: Object.h:82
void setIdent(std::string const &ident)
Set Ident: object identification string that is copied.
Definition: Object.h:218