LSSTApplications  16.0-10-g0ee56ad+5,16.0-11-ga33d1f2+5,16.0-12-g3ef5c14+3,16.0-12-g71e5ef5+18,16.0-12-gbdf3636+3,16.0-13-g118c103+3,16.0-13-g8f68b0a+3,16.0-15-gbf5c1cb+4,16.0-16-gfd17674+3,16.0-17-g7c01f5c+3,16.0-18-g0a50484+1,16.0-20-ga20f992+8,16.0-21-g0e05fd4+6,16.0-21-g15e2d33+4,16.0-22-g62d8060+4,16.0-22-g847a80f+4,16.0-25-gf00d9b8+1,16.0-28-g3990c221+4,16.0-3-gf928089+3,16.0-32-g88a4f23+5,16.0-34-gd7987ad+3,16.0-37-gc7333cb+2,16.0-4-g10fc685+2,16.0-4-g18f3627+26,16.0-4-g5f3a788+26,16.0-5-gaf5c3d7+4,16.0-5-gcc1f4bb+1,16.0-6-g3b92700+4,16.0-6-g4412fcd+3,16.0-6-g7235603+4,16.0-69-g2562ce1b+2,16.0-8-g14ebd58+4,16.0-8-g2df868b+1,16.0-8-g4cec79c+6,16.0-8-gadf6c7a+1,16.0-8-gfc7ad86,16.0-82-g59ec2a54a+1,16.0-9-g5400cdc+2,16.0-9-ge6233d7+5,master-g2880f2d8cf+3,v17.0.rc1
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends | List of all members
ast::Object Class Referenceabstract

Abstract base class for all AST objects. More...

#include <Object.h>

Inheritance diagram for ast::Object:
ast::Channel ast::KeyMap ast::Mapping ast::FitsChan ast::XmlChan ast::ChebyMap ast::CmpMap ast::Frame ast::LutMap ast::MathMap ast::MatrixMap ast::NormMap ast::PcdMap ast::PermMap ast::PolyMap ast::RateMap ast::ShiftMap ast::SlaMap ast::SphMap ast::TimeMap ast::TranMap ast::UnitMap ast::UnitNormMap ast::WcsMap ast::WinMap ast::ZoomMap

Public Types

using ObjectPtr = std::unique_ptr< AstObject, Deleter >
 unique pointer holding an AST raw pointer More...
 

Public Member Functions

virtual ~Object ()
 
 Object (Object const &object)
 Copy constructor: make a deep copy. More...
 
 Object (Object &&)=default
 
Objectoperator= (Object const &)=delete
 
Objectoperator= (Object &&)=default
 
bool operator== (Object const &rhs) const
 Return True if this and rhs are the equal. More...
 
bool operator!= (Object const &rhs) const
 Return True if this and rhs are not equal. More...
 
std::shared_ptr< Objectcopy () const
 Return a deep copy of this object. More...
 
void clear (std::string const &attrib)
 Clear the values of a specified set of attributes for an Object. More...
 
bool hasAttribute (std::string const &attrib) const
 Does this object have an attribute with the specified name? More...
 
std::string getClassName () const
 Get Class: the name of the class (e.g. More...
 
std::string getID () const
 Get ID: object identification string that is not copied. More...
 
std::string getIdent () const
 Get Ident: object identification string that is copied. More...
 
int getNObject () const
 Get NObject: number of AST objects in existence of the same type as the underlying AST class. More...
 
int getObjSize () const
 Get ObjSize: the in-memory size of the AST object in bytes. More...
 
int getRefCount () const
 Get RefCount: number of active pointers to the underlying AST object. More...
 
bool getUseDefs () const
 Get UseDefs: allow use of default values for Object attributes? More...
 
void lock (bool wait)
 Lock this object for exclusive use by the calling thread. More...
 
bool same (Object const &other) const
 Does this contain the same AST object as another? More...
 
void setID (std::string const &id)
 Set ID: object identification string that is not copied. More...
 
void setIdent (std::string const &ident)
 Set Ident: object identification string that is copied. More...
 
void setUseDefs (bool usedefs)
 Set UseDefs: allow use of default values for Object attributes? More...
 
void show (std::ostream &os, bool showComments=true) const
 Print a textual description the object to an ostream. More...
 
std::string show (bool showComments=true) const
 Return a textual description the object as a string. More...
 
bool test (std::string const &attrib) const
 Has this attribute been explicitly set (and not subsequently cleared)? More...
 
void unlock (bool report=false)
 Unlock this object previously locked using lock, so that other threads can use this object. More...
 
AstObject const * getRawPtr () const
 Get the raw AST pointer. More...
 
AstObject * getRawPtr ()
 Get the raw AST pointer. More...
 

Static Public Member Functions

static std::shared_ptr< ObjectfromString (std::string const &str)
 Construct an Object from a string, using astFromString. More...
 
template<typename Class >
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. More...
 

Protected Member Functions

 Object (AstObject *object)
 Construct an Object from a pointer to a raw AstObject. More...
 
template<typename T , typename AstT >
std::shared_ptr< T > copyImpl () const
 Implementation of deep copy. More...
 
virtual std::shared_ptr< ObjectcopyPolymorphic () const =0
 Return a deep copy of this object. More...
 
bool getB (std::string const &attrib) const
 Get the value of an attribute as a bool. More...
 
std::string const getC (std::string const &attrib) const
 Get the value of an attribute as a string. More...
 
double getD (std::string const &attrib) const
 Get the value of an attribute as a double. More...
 
float getF (std::string const &attrib) const
 Get the value of an attribute as a float. More...
 
int getI (std::string const &attrib) const
 Get the value of an attribute as an int. More...
 
long int getL (std::string const &attrib) const
 Get the value of an attribute as a long int. More...
 
void set (std::string const &setting)
 Assign a set of attribute values, over-riding any previous values. More...
 
void setB (std::string const &attrib, bool value)
 Set the value of an attribute as a bool. More...
 
void setC (std::string const &attrib, std::string const &value)
 Set the value of an attribute as a string. More...
 
void setD (std::string const &attrib, double value)
 Set the value of an attribute as a double. More...
 
void setF (std::string const &attrib, float value)
 Set the value of an attribute as a float. More...
 
void setI (std::string const &attrib, int value)
 Set the value of an attribute as an int. More...
 
void setL (std::string const &attrib, long int value)
 Set the value of an attribute as a long int. More...
 

Static Protected Member Functions

template<typename ShimT , typename AstT >
static std::shared_ptr< ShimT > makeShim (AstObject *p)
 Functor to make an astshim instance from a raw AST pointer of the corresponding type. More...
 

Friends

class MapSplit
 
class FrameDict
 

Detailed Description

Abstract base class for all AST objects.

Attributes

Object provides the following attributes:

Definition at line 51 of file Object.h.

Member Typedef Documentation

◆ ObjectPtr

using ast::Object::ObjectPtr = std::unique_ptr<AstObject, Deleter>

unique pointer holding an AST raw pointer

Definition at line 59 of file Object.h.

Constructor & Destructor Documentation

◆ ~Object()

virtual ast::Object::~Object ( )
inlinevirtual

Definition at line 61 of file Object.h.

61 {}

◆ Object() [1/3]

ast::Object::Object ( Object const &  object)
inline

Copy constructor: make a deep copy.

Definition at line 64 of file Object.h.

64 : _objPtr(object.getRawPtrCopy(), &detail::annulAstObject) {}
void annulAstObject(AstObject *object)
A wrapper around astAnnul; intended as a custom deleter for std::unique_ptr.
Definition: utils.h:40

◆ Object() [2/3]

ast::Object::Object ( Object &&  )
default

◆ Object() [3/3]

ast::Object::Object ( AstObject *  object)
explicitprotected

Construct an Object from a pointer to a raw AstObject.

Definition at line 165 of file Object.cc.

165  : _objPtr(object, &detail::annulAstObject) {
166  assertOK();
167  if (!object) {
168  throw std::runtime_error("Null pointer");
169  }
170 }
void annulAstObject(AstObject *object)
A wrapper around astAnnul; intended as a custom deleter for std::unique_ptr.
Definition: utils.h:40
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

Member Function Documentation

◆ clear()

void ast::Object::clear ( std::string const &  attrib)
inline

Clear the values of a specified set of attributes for an Object.

Clearing an attribute cancels any value that has previously been explicitly set for it, so that the standard default attribute value will subsequently be used instead. This also causes the astTest function to return the value zero for the attribute, indicating that no value has been set.

Definition at line 118 of file Object.h.

118  {
119  astClear(getRawPtr(), attrib.c_str());
120  assertOK();
121  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ copy()

std::shared_ptr<Object> ast::Object::copy ( ) const
inline

Return a deep copy of this object.

Definition at line 108 of file Object.h.

virtual std::shared_ptr< Object > copyPolymorphic() const =0
Return a deep copy of this object.
Object(Object const &object)
Copy constructor: make a deep copy.
Definition: Object.h:64
T static_pointer_cast(T... args)

◆ copyImpl()

template<typename T , typename AstT >
std::shared_ptr<T> ast::Object::copyImpl ( ) const
inlineprotected

Implementation of deep copy.

Should be called to implement copyPolymorphic by all derived classes.

Definition at line 319 of file Object.h.

319  {
320  auto *rawptr = reinterpret_cast<AstT *>(astCopy(getRawPtr()));
321  auto retptr = std::shared_ptr<T>(new T(rawptr));
322  assertOK();
323  return retptr;
324  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ copyPolymorphic()

virtual std::shared_ptr<Object> ast::Object::copyPolymorphic ( ) const
protectedpure virtual

Return a deep copy of this object.

This is called by copy.

Each subclass must override this method. The standard implementation is:

return copyImpl<astshim_class, ast_class>();

for example Frame implements this as:

return copyImpl<Frame, AstFrame>();

Implemented in ast::Frame, ast::KeyMap, ast::FrameSet, ast::Mapping, ast::MathMap, ast::ChebyMap, ast::SpecFrame, ast::FrameDict, ast::WcsMap, ast::SkyFrame, ast::PolyMap, ast::TimeMap, ast::SlaMap, ast::Channel, ast::TimeFrame, ast::PcdMap, ast::CmpMap, ast::LutMap, ast::CmpFrame, ast::PermMap, ast::MatrixMap, ast::RateMap, ast::ParallelMap, ast::SeriesMap, ast::TranMap, ast::SphMap, ast::UnitNormMap, ast::ZoomMap, ast::WinMap, ast::NormMap, ast::UnitMap, and ast::ShiftMap.

◆ fromAstObject()

template<typename Class >
template std::shared_ptr< Object > ast::Object::fromAstObject< Object > ( AstObject *  rawObj,
bool  copy 
)
static

Given a bare AST object pointer return a shared pointer to an ast::Object of the correct type.

The returned object takes ownership of the pointer. This is almost always what you want, for instance astDecompose returns shallow copies of the internal pointers.

Template Parameters
ClassThe class of the returned shared pointer. (The actual class will be the correct class of rawPtr.)
Parameters
[in]rawObjA bare AST object pointer
[in]copyIf True then make a deep copy of the pointer (and free the original)

Definition at line 132 of file Object.cc.

132  {
133  AstObject *rawObjCopy = rawObj;
134  if (copy) {
135  rawObjCopy = reinterpret_cast<AstObject *>(astCopy(rawObj));
136  astAnnul(rawObj);
137  }
138  assertOK(rawObjCopy);
139 
140  // Make the appropriate ast shim object and dynamically cast to the desired output type
141  auto retObjectBeforeCast = Object::_basicFromAstObject(rawObjCopy);
142  auto retObject = std::dynamic_pointer_cast<Class>(retObjectBeforeCast);
143  if (!retObject) {
145  os << "The component is of type " << retObject->getClassName()
146  << ", which could not be cast to the desired type " << typeid(Class).name();
147  throw std::runtime_error(os.str());
148  }
149  return retObject;
150 }
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::shared_ptr< Object > copy() const
Return a deep copy of this object.
Definition: Object.h:108
T str(T... args)
T dynamic_pointer_cast(T... args)
std::ostream * os
Definition: Schema.cc:746

◆ fromString()

static std::shared_ptr<Object> ast::Object::fromString ( std::string const &  str)
inlinestatic

Construct an Object from a string, using astFromString.

Definition at line 88 of file Object.h.

88  {
89  auto *rawPtr = reinterpret_cast<AstObject *>(astFromString(str.c_str()));
90  return Object::_basicFromAstObject(rawPtr);
91  }

◆ getB()

bool ast::Object::getB ( std::string const &  attrib) const
inlineprotected

Get the value of an attribute as a bool.

If possible, the attribute value is converted to the type you request.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 347 of file Object.h.

347  {
348  bool val = astGetI(getRawPtr(), attrib.c_str());
349  assertOK();
350  return val;
351  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
ImageT val
Definition: CR.cc:146

◆ getC()

std::string const ast::Object::getC ( std::string const &  attrib) const
inlineprotected

Get the value of an attribute as a string.

If possible, the attribute value is converted to the type you request.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 360 of file Object.h.

360  {
361  char const *rawval = astGetC(getRawPtr(), attrib.c_str());
362  assertOK();
363  return std::string(rawval);
364  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
STL class.

◆ getClassName()

std::string ast::Object::getClassName ( ) const
inline

Get Class: the name of the class (e.g.

ZoomMap)

Note: if AST returns "CmpMap" then the name will be changed to "SeriesMap" or "ParallelMap", as appropriate.

Definition at line 138 of file Object.h.

138 { return detail::getClassName(getRawPtr()); }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
std::string getClassName(AstObject const *rawObj)
Get the AST class name, changing CmpMap to SeriesMap or ParallelMap as appropriate.
Definition: utils.cc:37

◆ getD()

double ast::Object::getD ( std::string const &  attrib) const
inlineprotected

Get the value of an attribute as a double.

If possible, the attribute value is converted to the type you request.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 373 of file Object.h.

373  {
374  double val = astGetD(getRawPtr(), attrib.c_str());
375  assertOK();
376  return val;
377  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
ImageT val
Definition: CR.cc:146

◆ getF()

float ast::Object::getF ( std::string const &  attrib) const
inlineprotected

Get the value of an attribute as a float.

If possible, the attribute value is converted to the type you request.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 386 of file Object.h.

386  {
387  float val = astGetF(getRawPtr(), attrib.c_str());
388  assertOK();
389  return val;
390  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
ImageT val
Definition: CR.cc:146

◆ getI()

int ast::Object::getI ( std::string const &  attrib) const
inlineprotected

Get the value of an attribute as an int.

If possible, the attribute value is converted to the type you request.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 399 of file Object.h.

399  {
400  int val = astGetI(getRawPtr(), attrib.c_str());
401  assertOK();
402  return val;
403  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
ImageT val
Definition: CR.cc:146

◆ getID()

std::string ast::Object::getID ( ) const
inline

Get ID: object identification string that is not copied.

Definition at line 141 of file Object.h.

141 { return getC("ID"); }
std::string const getC(std::string const &attrib) const
Get the value of an attribute as a string.
Definition: Object.h:360

◆ getIdent()

std::string ast::Object::getIdent ( ) const
inline

Get Ident: object identification string that is copied.

Definition at line 144 of file Object.h.

144 { return getC("Ident"); }
std::string const getC(std::string const &attrib) const
Get the value of an attribute as a string.
Definition: Object.h:360

◆ getL()

long int ast::Object::getL ( std::string const &  attrib) const
inlineprotected

Get the value of an attribute as a long int.

If possible, the attribute value is converted to the type you request.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 412 of file Object.h.

412  {
413  long int val = astGetL(getRawPtr(), attrib.c_str());
414  assertOK();
415  return val;
416  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
ImageT val
Definition: CR.cc:146

◆ getNObject()

int ast::Object::getNObject ( ) const
inline

Get NObject: number of AST objects in existence of the same type as the underlying AST class.

Warning
Intended only for debugging astshim.

Definition at line 152 of file Object.h.

152 { return getI("NObject"); }
int getI(std::string const &attrib) const
Get the value of an attribute as an int.
Definition: Object.h:399

◆ getObjSize()

int ast::Object::getObjSize ( ) const
inline

Get ObjSize: the in-memory size of the AST object in bytes.

Definition at line 155 of file Object.h.

155 { return getI("ObjSize"); }
int getI(std::string const &attrib) const
Get the value of an attribute as an int.
Definition: Object.h:399

◆ getRawPtr() [1/2]

AstObject const* ast::Object::getRawPtr ( ) const
inline

Get the raw AST pointer.

Intended for internal use only, but cannot be made protected without endless "friend class" declarations.

Definition at line 291 of file Object.h.

291 { return &*_objPtr; };

◆ getRawPtr() [2/2]

AstObject* ast::Object::getRawPtr ( )
inline

Get the raw AST pointer.

Intended for internal use only, but cannot be made protected without endless "friend class" declarations.

Definition at line 293 of file Object.h.

293 { return &*_objPtr; };

◆ getRefCount()

int ast::Object::getRefCount ( ) const
inline

Get RefCount: number of active pointers to the underlying AST object.

Warning
Intended only for debugging astshim.

Definition at line 162 of file Object.h.

162 { return getI("RefCount"); }
int getI(std::string const &attrib) const
Get the value of an attribute as an int.
Definition: Object.h:399

◆ getUseDefs()

bool ast::Object::getUseDefs ( ) const
inline

Get UseDefs: allow use of default values for Object attributes?

Definition at line 165 of file Object.h.

165 { return getB("UseDefs"); }
bool getB(std::string const &attrib) const
Get the value of an attribute as a bool.
Definition: Object.h:347

◆ hasAttribute()

bool ast::Object::hasAttribute ( std::string const &  attrib) const
inline

Does this object have an attribute with the specified name?

Definition at line 126 of file Object.h.

126  {
127  bool ret = astHasAttribute(getRawPtr(), attrib.c_str());
128  assertOK();
129  return ret;
130  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ lock()

void ast::Object::lock ( bool  wait)
inline

Lock this object for exclusive use by the calling thread.

The thread-safe public interface to AST is designed so that an error is reported if any thread attempts to use an Object that it has not previously locked for its own exclusive use using this function. When an Object is created, it is initially locked by the thread that creates it, so newly created objects do not need to be explicitly locked. However, if an Object pointer is passed to another thread, the original thread must first unlock it (using astUnlock) and the new thread must then lock it (using astLock) before the new thread can use the Object.

Parameters
[in]waitIf the Object is curently locked by another thread then this function will either report an error or block. If a non-zero value is supplied for "wait", the calling thread waits until the object is available for it to use. Otherwise, an error is reported and the function returns immediately without locking the Object.

Notes

  • The Locked object will belong to the current AST context.
  • This function returns without action if the Object is already locked by the calling thread.
  • If simultaneous use of the same object is required by two or more threads, Object::copy should be used to to produce a deep copy of the Object for each thread. Each copy should then be unlocked by the parent thread (i.e. the thread that created the copy), and then locked by the child thread (i.e. the thread that wants to use the copy).
  • This function returns without action if the AST library has been built without POSIX thread support (i.e. the "-with-pthreads" option was not specified when running the "configure" script).

Definition at line 201 of file Object.h.

201  {
202  astLock(getRawPtr(), static_cast<int>(wait));
203  assertOK();
204  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ makeShim()

template<typename ShimT , typename AstT >
static std::shared_ptr<ShimT> ast::Object::makeShim ( AstObject *  p)
inlinestaticprotected

Functor to make an astshim instance from a raw AST pointer of the corresponding type.

Template Parameters
ShimTOutput astshim class
AstTOutput AST class

Definition at line 309 of file Object.h.

309  {
310  return std::shared_ptr<ShimT>(new ShimT(reinterpret_cast<AstT *>(p)));
311  }

◆ operator!=()

bool ast::Object::operator!= ( Object const &  rhs) const
inline

Return True if this and rhs are not equal.

See operator== for details

Definition at line 82 of file Object.h.

82  {
83  return !(*this == rhs); };

◆ operator=() [1/2]

Object& ast::Object::operator= ( Object const &  )
delete

◆ operator=() [2/2]

Object& ast::Object::operator= ( Object &&  )
default

◆ operator==()

bool ast::Object::operator== ( Object const &  rhs) const

Return True if this and rhs are the equal.

For two objects be equal, they both must have the same attributes and all contained objects must be equal.

Definition at line 82 of file Object.cc.

82  {
83  auto thisStr = this->show(false);
84  auto rhsStr = rhs.show(false);
85  return rhsStr == thisStr;
86 }
void show(std::ostream &os, bool showComments=true) const
Print a textual description the object to an ostream.
Definition: Object.cc:152

◆ same()

bool ast::Object::same ( Object const &  other) const
inline

Does this contain the same AST object as another?

This is a test of identity, not of equality.

Definition at line 211 of file Object.h.

211 { return astSame(getRawPtr(), other.getRawPtr()); }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
ItemVariant const * other
Definition: Schema.cc:56

◆ set()

void ast::Object::set ( std::string const &  setting)
inlineprotected

Assign a set of attribute values, over-riding any previous values.

The attributes and their new values are specified via a character string, which should contain a comma-separated list of the form: "attribute_1 = value_1, attribute_2 = value_2, ... " where "attribute_n" specifies an attribute name, and the value to the right of each " =" sign should be a suitable textual representation of the value to be assigned. This value will be interpreted according to the attribute's data type.

Notes

  • Attribute names are not case sensitive and may be surrounded by white space
  • Attribute names are not case sensitive and may be surrounded by white space.
  • White space may also surround attribute values, where it will generally be ignored (except for string-valued attributes where it is significant and forms part of the value to be assigned).
  • To include a literal comma or percent sign in the value assigned to an attribute, the whole attribute value should be enclosed in quotation markes.
Exceptions
std::runtime_errorif the attribute is read-only

Definition at line 439 of file Object.h.

439 { astSet(getRawPtr(), "%s", setting.c_str()); }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291

◆ setB()

void ast::Object::setB ( std::string const &  attrib,
bool  value 
)
inlineprotected

Set the value of an attribute as a bool.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 448 of file Object.h.

448  {
449  astSetI(getRawPtr(), attrib.c_str(), value);
450  assertOK();
451  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setC()

void ast::Object::setC ( std::string const &  attrib,
std::string const &  value 
)
inlineprotected

Set the value of an attribute as a string.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 460 of file Object.h.

460  {
461  astSetC(getRawPtr(), attrib.c_str(), value.c_str());
462  assertOK();
463  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setD()

void ast::Object::setD ( std::string const &  attrib,
double  value 
)
inlineprotected

Set the value of an attribute as a double.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 472 of file Object.h.

472  {
473  astSetD(getRawPtr(), attrib.c_str(), value);
474  assertOK();
475  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setF()

void ast::Object::setF ( std::string const &  attrib,
float  value 
)
inlineprotected

Set the value of an attribute as a float.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 484 of file Object.h.

484  {
485  astSetF(getRawPtr(), attrib.c_str(), value);
486  assertOK();
487  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setI()

void ast::Object::setI ( std::string const &  attrib,
int  value 
)
inlineprotected

Set the value of an attribute as an int.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 496 of file Object.h.

496  {
497  astSetI(getRawPtr(), attrib.c_str(), value);
498  assertOK();
499  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setID()

void ast::Object::setID ( std::string const &  id)
inline

Set ID: object identification string that is not copied.

Definition at line 214 of file Object.h.

214 { setC("ID", id); }
void setC(std::string const &attrib, std::string const &value)
Set the value of an attribute as a string.
Definition: Object.h:460

◆ setIdent()

void ast::Object::setIdent ( std::string const &  ident)
inline

Set Ident: object identification string that is copied.

Definition at line 217 of file Object.h.

217 { setC("Ident", ident); }
void setC(std::string const &attrib, std::string const &value)
Set the value of an attribute as a string.
Definition: Object.h:460

◆ setL()

void ast::Object::setL ( std::string const &  attrib,
long int  value 
)
inlineprotected

Set the value of an attribute as a long int.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 508 of file Object.h.

508  {
509  astSetL(getRawPtr(), attrib.c_str(), value);
510  assertOK();
511  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setUseDefs()

void ast::Object::setUseDefs ( bool  usedefs)
inline

Set UseDefs: allow use of default values for Object attributes?

Definition at line 220 of file Object.h.

220 { setB("UseDefs", usedefs); }
void setB(std::string const &attrib, bool value)
Set the value of an attribute as a bool.
Definition: Object.h:448

◆ show() [1/2]

void ast::Object::show ( std::ostream os,
bool  showComments = true 
) const

Print a textual description the object to an ostream.

Parameters
[in,out]osThe stream to which to write the string representation.
[in]showCommentsShow comments?

Definition at line 152 of file Object.cc.

152  {
153  Stream stream(nullptr, &os);
154  Channel ch(stream, showComments ? "" : "Comment=0");
155  ch.write(*this);
156  assertOK();
157 }
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ show() [2/2]

std::string ast::Object::show ( bool  showComments = true) const

Return a textual description the object as a string.

Parameters
[in]showCommentsShow comments?

Definition at line 159 of file Object.cc.

159  {
161  show(os, showComments);
162  return os.str();
163 }
T str(T... args)
void show(std::ostream &os, bool showComments=true) const
Print a textual description the object to an ostream.
Definition: Object.cc:152
std::ostream * os
Definition: Schema.cc:746

◆ test()

bool ast::Object::test ( std::string const &  attrib) const
inline

Has this attribute been explicitly set (and not subsequently cleared)?

Warning
Unlike the underlying astTest function, throws an exception if an error results

Notes

  • Attribute names are not case sensitive and may be surrounded by white space.
  • As you might expect, the returned value for a read-only attribute is always false.
Exceptions
std::runtime_errorif an error results.

Definition at line 249 of file Object.h.

249  {
250  bool res = astTest(getRawPtr(), attrib.c_str());
251  assertOK();
252  return res;
253  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ unlock()

void ast::Object::unlock ( bool  report = false)
inline

Unlock this object previously locked using lock, so that other threads can use this object.

See lock for further details.

Parameters
[in]reportIf true, an error will be reported if the supplied Object, or any Object contained within the supplied Object, is not currently locked by the running thread. If false, such Objects will be left unchanged, and no error will be reported.

Notes

  • This function attempts to execute even if AST's global error status is set, but no further error report will be made if it subsequently fails under these circumstances.
  • All unlocked Objects are excluded from AST context handling until they are re-locked using astLock.
  • This function returns without action if the Object is not currently locked by any thread. If it is locked by the running thread, it is unlocked. If it is locked by another thread, an error will be reported if "error" is non-zero.
  • This function returns without action if the AST library has been built without POSIX thread support (i.e. the "-with-pthreads" option was not specified when running the "configure" script).

Definition at line 279 of file Object.h.

279  {
280  astUnlock(getRawPtr(), static_cast<int>(report));
281  assertOK();
282  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

Friends And Related Function Documentation

◆ FrameDict

friend class FrameDict
friend

Definition at line 53 of file Object.h.

◆ MapSplit

friend class MapSplit
friend

Definition at line 52 of file Object.h.


The documentation for this class was generated from the following files: