22#ifndef ASTSHIM_OBJECT_H
23#define ASTSHIM_OBJECT_H
56 using Deleter = void (*)(AstObject *);
83 return !(*
this == rhs); };
89 auto *rawPtr =
reinterpret_cast<AstObject *
>(astFromString(str.
c_str()));
91 return Object::_basicFromAstObject(rawPtr);
105 template <
typename Class>
203 astLock(
getRawPtr(),
static_cast<int>(wait));
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>
319 template <
typename T,
typename AstT>
321 auto *rawptr =
reinterpret_cast<AstT *
>(astCopy(
getRawPtr()));
530 AstObject * getRawPtrCopy()
const {
531 AstObject * rawPtrCopy =
reinterpret_cast<AstObject *
>(astCopy(
getRawPtr()));
539 void swapRawPointers(Object &other)
noexcept {
540 swap(_objPtr, other._objPtr);
table::Key< std::string > object
A FrameSet whose frames can be referenced by domain name.
A Mapping split off as a subset of another Mapping.
Abstract base class for all AST objects.
static std::shared_ptr< Class > fromAstObject(AstObject *rawObj, bool copy)
Given a bare AST object pointer return a shared pointer to an ast::Object of the correct type.
Object(Object &&)=default
Object & operator=(Object &&)=default
void lock(bool wait)
Lock this object for exclusive use by the calling thread.
void show(std::ostream &os, bool showComments=true) const
Print a textual description the object to an ostream.
std::shared_ptr< T > copyImpl() const
Implementation of deep copy.
bool same(Object const &other) const
Does this contain the same AST object as another?
void setD(std::string const &attrib, double value)
Set the value of an attribute as a double.
bool operator!=(Object const &rhs) const
Return True if this and rhs are not equal.
double getD(std::string const &attrib) const
Get the value of an attribute as a double.
void setL(std::string const &attrib, long int value)
Set the value of an attribute as a long int.
std::shared_ptr< Object > copy() const
Return a deep copy of this object.
AstObject * getRawPtr()
Get the raw AST pointer.
long int getL(std::string const &attrib) const
Get the value of an attribute as a long int.
std::string const getC(std::string const &attrib) const
Get the value of an attribute as a string.
std::string getClassName() const
Get Class: the name of the class (e.g.
void setI(std::string const &attrib, int value)
Set the value of an attribute as an int.
static std::shared_ptr< ShimT > makeShim(AstObject *p)
Functor to make an astshim instance from a raw AST pointer of the corresponding type.
virtual std::shared_ptr< Object > copyPolymorphic() const =0
Return a deep copy of this object.
bool test(std::string const &attrib) const
Has this attribute been explicitly set (and not subsequently cleared)?
bool getB(std::string const &attrib) const
Get the value of an attribute as a bool.
bool getUseDefs() const
Get UseDefs: allow use of default values for Object attributes?
void setID(std::string const &id)
Set ID: object identification string that is not copied.
std::string getID() const
Get ID: object identification string that is not copied.
void clear(std::string const &attrib)
Clear the values of a specified set of attributes for an Object.
int getI(std::string const &attrib) const
Get the value of an attribute as an int.
void setF(std::string const &attrib, float value)
Set the value of an attribute as a float.
static std::shared_ptr< Object > fromString(std::string const &str)
Construct an Object from a string, using astFromString.
void unlock(bool report=false)
Unlock this object previously locked using lock, so that other threads can use this object.
std::unique_ptr< AstObject, Deleter > ObjectPtr
unique pointer holding an AST raw pointer
void setC(std::string const &attrib, std::string const &value)
Set the value of an attribute as a string.
float getF(std::string const &attrib) const
Get the value of an attribute as a float.
Object(Object const &object)
Copy constructor: make a deep copy.
std::string getIdent() const
Get Ident: object identification string that is copied.
void set(std::string const &setting)
Assign a set of attribute values, over-riding any previous values.
int getObjSize() const
Get ObjSize: the in-memory size of the AST object in bytes.
void setB(std::string const &attrib, bool value)
Set the value of an attribute as a bool.
Object & operator=(Object const &)=delete
AstObject const * getRawPtr() const
Get the raw AST pointer.
int getNObject() const
Get NObject: number of AST objects in existence of the same type as the underlying AST class.
void setIdent(std::string const &ident)
Set Ident: object identification string that is copied.
bool hasAttribute(std::string const &attrib) const
Does this object have an attribute with the specified name?
void setUseDefs(bool usedefs)
Set UseDefs: allow use of default values for Object attributes?
bool operator==(Object const &rhs) const
Return True if this and rhs are the equal.
int getRefCount() const
Get RefCount: number of active pointers to the underlying AST object.
std::string getClassName(AstObject const *rawObj)
Get the AST class name, changing CmpMap to SeriesMap or ParallelMap as appropriate.
AST wrapper classes and functions.
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST's state is bad.