lsst.astshim g45278abf61+052faf71bd
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

#include <Object.h>

Inheritance diagram for ast::Object:
ast::Channel ast::KeyMap ast::Mapping ast::FitsChan ast::XmlChan ast::Table 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
 
bool operator!= (Object const &rhs) const
 
std::shared_ptr< Objectcopy () const
 Return a deep copy of this object. More...
 
void clear (std::string const &attrib)
 
bool hasAttribute (std::string const &attrib) const
 
std::string getClassName () const
 
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
 
int getObjSize () const
 Get ObjSize: the in-memory size of the AST object in bytes. More...
 
int getRefCount () const
 
bool getUseDefs () const
 Get UseDefs: allow use of default values for Object attributes? More...
 
void lock (bool wait)
 
bool same (Object const &other) const
 
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
 
std::string show (bool showComments=true) const
 
bool test (std::string const &attrib) const
 
void unlock (bool report=false)
 
AstObject const * getRawPtr () const
 
AstObject * getRawPtr ()
 

Static Public Member Functions

static std::shared_ptr< ObjectfromString (std::string const &str)
 
template<typename Class >
static std::shared_ptr< Class > fromAstObject (AstObject *rawObj, bool copy)
 

Protected Member Functions

 Object (AstObject *object)
 
template<typename T , typename AstT >
std::shared_ptr< T > copyImpl () const
 
virtual std::shared_ptr< ObjectcopyPolymorphic () const =0
 
bool getB (std::string const &attrib) const
 
std::string const getC (std::string const &attrib) const
 
double getD (std::string const &attrib) const
 
float getF (std::string const &attrib) const
 
int getI (std::string const &attrib) const
 
long int getL (std::string const &attrib) const
 
void set (std::string const &setting)
 
void setB (std::string const &attrib, bool value)
 
void setC (std::string const &attrib, std::string const &value)
 
void setD (std::string const &attrib, double value)
 
void setF (std::string const &attrib, float value)
 
void setI (std::string const &attrib, int value)
 
void setL (std::string const &attrib, long int value)
 

Static Protected Member Functions

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

Friends

class MapSplit
 
class FrameDict
 

Detailed Description

Abstract base class for all AST objects

Attributes

Object provides the following attributes:

Member Typedef Documentation

◆ ObjectPtr

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

unique pointer holding an AST raw pointer

Constructor & Destructor Documentation

◆ ~Object()

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

◆ Object() [1/3]

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

Copy constructor: make a deep copy.

◆ 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

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.

◆ copy()

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

Return a deep copy of this object.

◆ 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.

◆ 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::Channel, ast::ChebyMap, ast::CmpFrame, ast::CmpMap, ast::Frame, ast::FrameDict, ast::FrameSet, ast::KeyMap, ast::LutMap, ast::Mapping, ast::MathMap, ast::MatrixMap, ast::NormMap, ast::ParallelMap, ast::PcdMap, ast::PermMap, ast::PolyMap, ast::RateMap, ast::SeriesMap, ast::ShiftMap, ast::SkyFrame, ast::SlaMap, ast::SpecFrame, ast::SphMap, ast::TimeFrame, ast::TimeMap, ast::TranMap, ast::UnitMap, ast::UnitNormMap, ast::WcsMap, ast::WinMap, and ast::ZoomMap.

◆ 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)

◆ fromString()

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

Construct an Object from a string, using astFromString

◆ 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

◆ 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

◆ 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.

◆ 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

◆ 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

◆ 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

◆ getID()

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

Get ID: object identification string that is not copied.

◆ getIdent()

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

Get Ident: object identification string that is copied.

◆ 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

◆ 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.

◆ getObjSize()

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

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

◆ getRawPtr() [1/2]

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

◆ getRawPtr() [2/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.

◆ getRefCount()

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

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

Warning
Intended only for debugging astshim.

◆ getUseDefs()

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

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

◆ hasAttribute()

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

Does this object have an attribute with the specified name?

◆ 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).

◆ 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

◆ operator!=()

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

Return True if this and rhs are not equal

See operator== for details

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ 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.

◆ 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.

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ setID()

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

Set ID: object identification string that is not copied.

◆ setIdent()

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

Set Ident: object identification string that is copied.

◆ 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

◆ setUseDefs()

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

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

◆ show() [1/2]

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

Return a textual description the object as a string.

Parameters
[in]showCommentsShow comments?

◆ show() [2/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?

◆ 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.

◆ 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).

Friends And Related Function Documentation

◆ FrameDict

friend class FrameDict
friend

◆ MapSplit

friend class MapSplit
friend

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