LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends | List of all members
ast::FitsTable Class Reference

#include <FitsTable.h>

Inheritance diagram for ast::FitsTable:
ast::Table ast::KeyMap ast::Object

Public Types

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

Public Member Functions

 FitsTable (FitsChan const &header, std::string const &options="")
 
 FitsTable (std::string const &options="")
 
virtual ~FitsTable ()
 
 FitsTable (FitsTable const &)=default
 
 FitsTable (FitsTable &&)=default
 
FitsTableoperator= (FitsTable const &)=delete
 
FitsTableoperator= (FitsTable &&)=default
 
std::shared_ptr< FitsChangetTableHeader () const
 
std::size_t columnSize (std::string const &column)
 
ndarray::Array< double, 1, 1 > getColumnData1D (std::string const &column)
 
std::string columnName (int index) const
 
DataType columnType (std::string const &column) const
 
int columnLength (std::string const &column) const
 
int columnLenC (std::string const &column) const
 
int columnNdim (std::string const &column) const
 
std::string columnUnit (std::string const &column) const
 
std::vector< int > columnShape (std::string const &column)
 
int getNColumn () const
 Get NColumn: The number of columns currently in the Table. More...
 
int getNRow () const
 Get NRow: The number of rows currently in the Table. More...
 
std::shared_ptr< KeyMapcopy () const
 Return a deep copy of this object. More...
 
bool defined (std::string const &key) const
 Does this map contain the specified key, and if so, does it have a defined value? More...
 
std::string key (int ind) const
 Get the key at the specified index. More...
 
bool hasKey (std::string const &key) const
 Does this map contain the specified key? More...
 
int length (std::string const &key) const
 Get the size of the vector for the specified key; return 0 if key not found or value is undefined. More...
 
int size () const
 Get the number of keys. More...
 
double getD (std::string const &key, int ind) const
 Get one double value for a given key. More...
 
std::vector< double > getD (std::string const &key) const
 Get all double values for a given key. More...
 
float getF (std::string const &key, int ind) const
 Get one float value for a given key. More...
 
std::vector< float > getF (std::string const &key) const
 Get all float values for a given key. More...
 
int getI (std::string const &key, int ind) const
 Get one int value for a given key. More...
 
std::vector< int > getI (std::string const &key) const
 Get all int values for a given key. More...
 
short int getS (std::string const &key, int ind) const
 Get one short int value for a given key. More...
 
std::vector< short int > getS (std::string const &key) const
 Get all short int values for a given key. More...
 
char unsigned getB (std::string const &key, int ind) const
 Get one char value for a given key. More...
 
std::vector< char unsigned > getB (std::string const &key) const
 Get all char values for a given key. More...
 
std::string getC (std::string const &key, int ind) const
 Get one std::string value for a given key. More...
 
std::vector< std::stringgetC (std::string const &key) const
 Get all std::string values for a given key. More...
 
std::shared_ptr< ObjectgetA (std::string const &key, int ind) const
 Get one Object for a given key; the object is deep copied. More...
 
std::vector< std::shared_ptr< Object > > getA (std::string const &key) const
 Get all Objects for a given key; each object is deep copied. More...
 
void putD (std::string const &key, double value, std::string const &comment="")
 Add a double value. More...
 
void putD (std::string const &key, std::vector< double > const &vec, std::string const &comment="")
 Add a vector of double. More...
 
void putF (std::string const &key, float value, std::string const &comment="")
 Add a float. More...
 
void putF (std::string const &key, std::vector< float > const &vec, std::string const &comment="")
 Add a vector of floats. More...
 
void putI (std::string const &key, int value, std::string const &comment="")
 Add an int. More...
 
void putI (std::string const &key, std::vector< int > const &vec, std::string const &comment="")
 Add a vector of ints. More...
 
void putS (std::string const &key, short int value, std::string const &comment="")
 Add a short int. More...
 
void putS (std::string const &key, std::vector< short int > const &vec, std::string const &comment="")
 Add a vector of short int. More...
 
void putB (std::string const &key, char unsigned value, std::string const &comment="")
 Add a char. More...
 
void putB (std::string const &key, std::vector< char unsigned > const &vec, std::string const &comment="")
 Add a vector of chars. More...
 
void putC (std::string const &key, std::string const &value, std::string const &comment="")
 Add a string. More...
 
void putC (std::string const &key, std::vector< std::string > const &vec, std::string const &comment="")
 Add a vector of strings. More...
 
void putA (std::string const &key, Object const &obj, std::string const &comment="")
 Add an Object, which is deep copied. More...
 
void putA (std::string const &key, std::vector< std::shared_ptr< Object const > > const &vec, std::string const &comment="")
 Add a vector of shared pointer to Object; the objects are deep copied. More...
 
void putU (std::string const &key, std::string const &comment="")
 Add a new entry, but no value is stored with the entry. More...
 
void append (std::string const &key, double value)
 Append an element to a vector of doubles in a KeyMap. More...
 
void append (std::string const &key, float value)
 Append an element to a vector of floats in a KeyMap. More...
 
void append (std::string const &key, int value)
 Append an element to a vector of ints in a KeyMap. More...
 
void append (std::string const &key, short int value)
 Append an element to a vector of short int in a KeyMap. More...
 
void append (std::string const &key, char unsigned value)
 Append an element to a vector of char in a KeyMap. More...
 
void append (std::string const &key, std::string const &value)
 Append an element to a vector of strings in a KeyMap. More...
 
void append (std::string const &key, Object const &value)
 Append an element to a vector of Objects in a KeyMap. More...
 
void replace (std::string const &key, int i, double value)
 Replace an element of a vector of doubles in a KeyMap. More...
 
void replace (std::string const &key, int i, float value)
 Replace an element of a vector of floats in a KeyMap. More...
 
void replace (std::string const &key, int i, int value)
 Replace an element of a vector of ints in a KeyMap. More...
 
void replace (std::string const &key, int i, short int value)
 Replace an element of a vector of short int in a KeyMap. More...
 
void replace (std::string const &key, int i, char unsigned value)
 Replace an element of a vector of char in a KeyMap. More...
 
void replace (std::string const &key, int i, std::string const &value)
 Replace an element of a vector of strings in a KeyMap. More...
 
void replace (std::string const &key, int i, Object const &value)
 Replace an element of a vector of Objects in a KeyMap. More...
 
void remove (std::string const &key)
 Remove the specified entry. More...
 
void rename (std::string const &oldKey, std::string const &newKey)
 Rename the specified entry. More...
 
DataType type (std::string const &key)
 Get the type suffix for a given key. More...
 
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...
 
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

 FitsTable (AstFitsTable *rawFitsTable)
 Construct a FitsTable from a raw AstFitsTable. More...
 
virtual std::shared_ptr< ObjectcopyPolymorphic () const override
 Return a deep copy of this object. More...
 
template<typename T , typename AstT >
std::shared_ptr< T > copyImpl () const
 Implementation of deep copy. 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 Object
 

Detailed Description

Definition at line 38 of file FitsTable.h.

Member Typedef Documentation

◆ ObjectPtr

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

unique pointer holding an AST raw pointer

Definition at line 59 of file Object.h.

Constructor & Destructor Documentation

◆ FitsTable() [1/5]

ast::FitsTable::FitsTable ( FitsChan const &  header,
std::string const &  options = "" 
)
inlineexplicit

Definition at line 42 of file FitsTable.h.

43 : Table(reinterpret_cast<AstTable *>(astFitsTable(const_cast<AstObject *>(header.getRawPtr()),
44 "%s", options.c_str()))) {
45 assertOK();;
46 }
Table(std::string const &options="")
Definition: Table.h:39
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST's state is bad.
Definition: base.cc:49

◆ FitsTable() [2/5]

ast::FitsTable::FitsTable ( std::string const &  options = "")
inlineexplicit

Definition at line 47 of file FitsTable.h.

48 : Table(reinterpret_cast<AstTable *>(astFitsTable(NULL,
49 "%s", options.c_str()))) {
50 assertOK();;
51 }

◆ ~FitsTable()

virtual ast::FitsTable::~FitsTable ( )
inlinevirtual

Definition at line 54 of file FitsTable.h.

54{};

◆ FitsTable() [3/5]

ast::FitsTable::FitsTable ( FitsTable const &  )
default

◆ FitsTable() [4/5]

ast::FitsTable::FitsTable ( FitsTable &&  )
default

◆ FitsTable() [5/5]

ast::FitsTable::FitsTable ( AstFitsTable *  rawFitsTable)
inlineexplicitprotected

Construct a FitsTable from a raw AstFitsTable.

Definition at line 103 of file FitsTable.h.

103 : Table(reinterpret_cast<AstTable *>(rawFitsTable)) {
104 if (!astIsAFitsTable(getRawPtr())) {
106 os << "this is a " << getClassName() << ", which is not a FitsTable";
107 throw std::invalid_argument(os.str());
108 }
109 assertOK();
110 }
std::ostream * os
Definition: Schema.cc:557
std::string getClassName() const
Get Class: the name of the class (e.g.
Definition: Object.h:139
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292

Member Function Documentation

◆ append() [1/7]

void ast::KeyMap::append ( std::string const &  key,
char unsigned  value 
)
inlineinherited

Append an element to a vector of char in a KeyMap.

Definition at line 482 of file KeyMap.h.

482 {
483 int const i = _getAppendIndex(key);
484 astMapPutElemB(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
485 assertOK();
486 }
T c_str(T... args)
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:125

◆ append() [2/7]

void ast::KeyMap::append ( std::string const &  key,
double  value 
)
inlineinherited

Append an element to a vector of doubles in a KeyMap.

Definition at line 454 of file KeyMap.h.

454 {
455 int const i = _getAppendIndex(key);
456 astMapPutElemD(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
457 assertOK();
458 }

◆ append() [3/7]

void ast::KeyMap::append ( std::string const &  key,
float  value 
)
inlineinherited

Append an element to a vector of floats in a KeyMap.

Definition at line 461 of file KeyMap.h.

461 {
462 int const i = _getAppendIndex(key);
463 astMapPutElemF(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
464 assertOK();
465 }

◆ append() [4/7]

void ast::KeyMap::append ( std::string const &  key,
int  value 
)
inlineinherited

Append an element to a vector of ints in a KeyMap.

Definition at line 468 of file KeyMap.h.

468 {
469 int const i = _getAppendIndex(key);
470 astMapPutElemI(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
471 assertOK();
472 }

◆ append() [5/7]

void ast::KeyMap::append ( std::string const &  key,
Object const &  value 
)
inlineinherited

Append an element to a vector of Objects in a KeyMap.

Definition at line 496 of file KeyMap.h.

496 {
497 int const i = _getAppendIndex(key);
498 AstObject *rawCopy = reinterpret_cast<AstObject *>(astCopy(value.getRawPtr()));
499 astMapPutElemA(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, rawCopy);
500 assertOK(rawCopy);
501 }

◆ append() [6/7]

void ast::KeyMap::append ( std::string const &  key,
short int  value 
)
inlineinherited

Append an element to a vector of short int in a KeyMap.

Definition at line 475 of file KeyMap.h.

475 {
476 int const i = _getAppendIndex(key);
477 astMapPutElemS(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
478 assertOK();
479 }

◆ append() [7/7]

void ast::KeyMap::append ( std::string const &  key,
std::string const &  value 
)
inlineinherited

Append an element to a vector of strings in a KeyMap.

Definition at line 489 of file KeyMap.h.

489 {
490 int const i = _getAppendIndex(key);
491 astMapPutElemC(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value.c_str());
492 assertOK();
493 }

◆ clear()

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

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 119 of file Object.h.

119 {
120 astClear(getRawPtr(), attrib.c_str());
121 assertOK();
122 }

◆ columnLenC()

int ast::Table::columnLenC ( std::string const &  column) const
inlineinherited

Definition at line 69 of file Table.h.

69 {
70 int retVal = Object::getI("ColumnLenC(" + column + ")");
71 assertOK();
72 return retVal;
73 }
int getI(std::string const &attrib) const
Get the value of an attribute as an int.
Definition: Object.h:400

◆ columnLength()

int ast::Table::columnLength ( std::string const &  column) const
inlineinherited

Definition at line 63 of file Table.h.

63 {
64 int retVal = Object::getI("ColumnLength(" + column + ")");
65 assertOK();
66 return retVal;
67 }

◆ columnName()

std::string ast::Table::columnName ( int  index) const
inlineinherited

Definition at line 51 of file Table.h.

51 {
52 std::string name = astColumnName(getRawPtr(), index);
53 assertOK();
54 return name;
55 }
table::Key< std::string > name
Definition: Amplifier.cc:116

◆ columnNdim()

int ast::Table::columnNdim ( std::string const &  column) const
inlineinherited

Definition at line 75 of file Table.h.

75 {
76 int retVal = Object::getI("ColumnNdim(" + column + ")");
77 assertOK();
78 return retVal;
79 }

◆ columnShape()

std::vector< int > ast::Table::columnShape ( std::string const &  column)
inlineinherited

Definition at line 87 of file Table.h.

87 {
88 int const mxdim = columnNdim(column);
89 std::vector<int> dims(mxdim);
90 if (mxdim > 0) {
91 int ndim;
92 astColumnShape(getRawPtr(), column.c_str(), mxdim, &ndim, dims.data());
93 }
94 assertOK();
95 return dims;
96 }
int columnNdim(std::string const &column) const
Definition: Table.h:75
table::Key< int > ndim
Definition: PsfexPsf.cc:325

◆ columnSize()

std::size_t ast::FitsTable::columnSize ( std::string const &  column)
inline

Definition at line 70 of file FitsTable.h.

70 {
71 size_t retVal = astColumnSize(getRawPtr(), column.c_str());
72 assertOK();
73 return retVal;
74 }

◆ columnType()

DataType ast::Table::columnType ( std::string const &  column) const
inlineinherited

Definition at line 57 of file Table.h.

57 {
58 int retVal = Object::getI("ColumnType(" + column + ")");
59 assertOK();
60 return static_cast<DataType>(retVal);
61 }
DataType
Data types held by a KeyMap.
Definition: base.h:62

◆ columnUnit()

std::string ast::Table::columnUnit ( std::string const &  column) const
inlineinherited

Definition at line 81 of file Table.h.

81 {
82 std::string retVal = Object::getC("ColumnUnit(" + column + ")");
83 assertOK();
84 return retVal;
85 }
std::string const getC(std::string const &attrib) const
Get the value of an attribute as a string.
Definition: Object.h:361

◆ copy()

std::shared_ptr< KeyMap > ast::KeyMap::copy ( ) const
inlineinherited

Return a deep copy of this object.

Definition at line 107 of file KeyMap.h.

107 {
108 return std::static_pointer_cast<KeyMap>(copyPolymorphic());
109 assertOK();
110 }
virtual std::shared_ptr< Object > copyPolymorphic() const override
Return a deep copy of this object.
Definition: KeyMap.h:584

◆ copyImpl()

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

Implementation of deep copy.

Should be called to implement copyPolymorphic by all derived classes.

Definition at line 320 of file Object.h.

320 {
321 auto *rawptr = reinterpret_cast<AstT *>(astCopy(getRawPtr()));
322 auto retptr = std::shared_ptr<T>(new T(rawptr));
323 assertOK();
324 return retptr;
325 }

◆ copyPolymorphic()

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

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>();

Implements ast::Object.

Definition at line 584 of file KeyMap.h.

584 {
585 return std::static_pointer_cast<KeyMap>(copyImpl<KeyMap, AstKeyMap>());
586 }

◆ defined()

bool ast::KeyMap::defined ( std::string const &  key) const
inlineinherited

Does this map contain the specified key, and if so, does it have a defined value?

See also hasKey, which does not check if the value is defined

Definition at line 117 of file KeyMap.h.

117 {
118 bool ret = static_cast<bool>(
119 astMapDefined(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str()));
120 assertOK();
121 return ret;
122 }

◆ fromAstObject()

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

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 138 of file Object.cc.

138 {
139 AstObject *rawObjCopy = rawObj;
140 if (copy) {
141 rawObjCopy = reinterpret_cast<AstObject *>(astCopy(rawObj));
142 astAnnul(rawObj);
143 }
144 assertOK(rawObjCopy);
145
146 // Make the appropriate ast shim object and dynamically cast to the desired output type
147 auto retObjectBeforeCast = Object::_basicFromAstObject(rawObjCopy);
148 auto retObject = std::dynamic_pointer_cast<Class>(retObjectBeforeCast);
149 if (!retObject) {
151 os << "The component is of type " << retObject->getClassName()
152 << ", which could not be cast to the desired type " << typeid(Class).name();
153 throw std::runtime_error(os.str());
154 }
155 return retObject;
156}
std::shared_ptr< Object > copy() const
Return a deep copy of this object.
Definition: Object.h:109

◆ fromString()

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

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 assertOK(rawPtr);
91 return Object::_basicFromAstObject(rawPtr);
92 }

◆ getA() [1/2]

std::vector< std::shared_ptr< Object > > ast::KeyMap::getA ( std::string const &  key) const
inlineinherited

Get all Objects for a given key; each object is deep copied.

Definition at line 321 of file KeyMap.h.

321 {
322 int const size = length(key);
324 for (int i = 0; i < size; ++i) {
325 retVec.push_back(getA(key, i));
326 }
327 return retVec;
328 }
int length(std::string const &key) const
Get the size of the vector for the specified key; return 0 if key not found or value is undefined.
Definition: KeyMap.h:150
int size() const
Get the number of keys.
Definition: KeyMap.h:157
std::shared_ptr< Object > getA(std::string const &key, int ind) const
Get one Object for a given key; the object is deep copied.
Definition: KeyMap.h:310
T push_back(T... args)

◆ getA() [2/2]

std::shared_ptr< Object > ast::KeyMap::getA ( std::string const &  key,
int  ind 
) const
inlineinherited

Get one Object for a given key; the object is deep copied.

Definition at line 310 of file KeyMap.h.

310 {
312 AstObject *rawObj;
313 if (!astMapGetElemA(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &rawObj)) {
314 throwKeyNotFound(key);
315 }
316 assertOK();
317 return Object::fromAstObject<Object>(rawObj, true);
318 }

◆ getB() [1/2]

std::vector< char unsigned > ast::KeyMap::getB ( std::string const &  key) const
inlineinherited

Get all char values for a given key.

Definition at line 266 of file KeyMap.h.

266 {
267 int const size = length(key);
269 if (size > 0) {
270 int nret; // should equal size after the call
271 astMapGet1B(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
272 retVec.data());
273 }
274 assertOK();
275 return retVec;
276 }

◆ getB() [2/2]

char unsigned ast::KeyMap::getB ( std::string const &  key,
int  ind 
) const
inlineinherited

Get one char value for a given key.

Definition at line 256 of file KeyMap.h.

256 {
257 char unsigned retVal;
258 if (!astMapGetElemB(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
259 throwKeyNotFound(key);
260 }
261 assertOK();
262 return retVal;
263 }

◆ getC() [1/2]

std::vector< std::string > ast::KeyMap::getC ( std::string const &  key) const
inlineinherited

Get all std::string values for a given key.

Definition at line 291 of file KeyMap.h.

291 {
292 int const size = length(key);
294 if (size > 0) {
295 // # of chars for each entry; the +1 is needed to provide space for the terminating null
296 int const eltLen = 1 + astMapLenC(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str());
297 std::unique_ptr<char[]> cstr(new char[size * eltLen]);
298 int nret; // should equal size after the call
299 astMapGet1C(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), eltLen, size, &nret,
300 cstr.get());
301 for (int i = 0; i < size; ++i) {
302 retVec.push_back(std::string(cstr.get() + i * eltLen));
303 }
304 }
305 assertOK();
306 return retVec;
307 }

◆ getC() [2/2]

std::string ast::KeyMap::getC ( std::string const &  key,
int  ind 
) const
inlineinherited

Get one std::string value for a given key.

Definition at line 279 of file KeyMap.h.

279 {
280 int const maxChar = 1 + astMapLenC(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str());
281 std::unique_ptr<char[]> cstr(new char[maxChar]);
282 if (!astMapGetElemC(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), maxChar, ind,
283 cstr.get())) {
284 throwKeyNotFound(key);
285 }
286 assertOK();
287 return std::string(cstr.get());
288 }

◆ getClassName()

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

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 139 of file Object.h.

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

◆ getColumnData1D()

ndarray::Array< double, 1, 1 > ast::FitsTable::getColumnData1D ( std::string const &  column)
inline

Definition at line 79 of file FitsTable.h.

79 {
80 auto dtype = columnType(column);
82 throw std::runtime_error("Data type not supported by getColumnData");
83 }
84 // We can ask AST for the number of bytes required but for now
85 // calculate the number of elements from the shape and rows
86 auto totnel = getNRow();
87 auto shape = columnShape(column);
88 for (auto &val : shape) {
89 totnel *= val;
90 }
91 ndarray::Array<double, 1, 1> coldata = ndarray::allocate(ndarray::makeVector(totnel));
92 int nelem;
93 astGetColumnData(getRawPtr(), column.c_str(), AST__NANF, AST__NAN, totnel*sizeof(double),
94 coldata.getData(), &nelem);
95 return coldata;
96 }
std::vector< int > columnShape(std::string const &column)
Definition: Table.h:87
DataType columnType(std::string const &column) const
Definition: Table.h:57
int getNRow() const
Get NRow: The number of rows currently in the Table.
Definition: Table.h:106
ImageT val
Definition: CR.cc:146

◆ getD() [1/2]

std::vector< double > ast::KeyMap::getD ( std::string const &  key) const
inlineinherited

Get all double values for a given key.

Definition at line 174 of file KeyMap.h.

174 {
175 int const size = length(key);
177 if (size > 0) {
178 int nret; // should equal size after the call
179 astMapGet1D(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
180 retVec.data());
181 }
182 assertOK();
183 return retVec;
184 }

◆ getD() [2/2]

double ast::KeyMap::getD ( std::string const &  key,
int  ind 
) const
inlineinherited

Get one double value for a given key.

Definition at line 164 of file KeyMap.h.

164 {
165 double retVal;
166 if (!astMapGetElemD(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
167 throwKeyNotFound(key);
168 }
169 assertOK();
170 return retVal;
171 }

◆ getF() [1/2]

std::vector< float > ast::KeyMap::getF ( std::string const &  key) const
inlineinherited

Get all float values for a given key.

Definition at line 197 of file KeyMap.h.

197 {
198 int const size = length(key);
199 std::vector<float> retVec(size);
200 if (size > 0) {
201 int nret; // should equal size after the call
202 astMapGet1F(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
203 retVec.data());
204 }
205 assertOK();
206 return retVec;
207 }

◆ getF() [2/2]

float ast::KeyMap::getF ( std::string const &  key,
int  ind 
) const
inlineinherited

Get one float value for a given key.

Definition at line 187 of file KeyMap.h.

187 {
188 float retVal;
189 if (!astMapGetElemF(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
190 throwKeyNotFound(key);
191 }
192 assertOK();
193 return retVal;
194 }

◆ getI() [1/2]

std::vector< int > ast::KeyMap::getI ( std::string const &  key) const
inlineinherited

Get all int values for a given key.

Definition at line 220 of file KeyMap.h.

220 {
221 int const size = length(key);
222 std::vector<int> retVec(size);
223 if (size > 0) {
224 int nret; // should equal size after the call
225 astMapGet1I(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
226 retVec.data());
227 }
228 assertOK();
229 return retVec;
230 }

◆ getI() [2/2]

int ast::KeyMap::getI ( std::string const &  key,
int  ind 
) const
inlineinherited

Get one int value for a given key.

Definition at line 210 of file KeyMap.h.

210 {
211 int retVal;
212 if (!astMapGetElemI(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
213 throwKeyNotFound(key);
214 }
215 assertOK();
216 return retVal;
217 }

◆ getID()

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

Get ID: object identification string that is not copied.

Definition at line 142 of file Object.h.

142{ return getC("ID"); }

◆ getIdent()

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

Get Ident: object identification string that is copied.

Definition at line 145 of file Object.h.

145{ return getC("Ident"); }

◆ getL()

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

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 413 of file Object.h.

413 {
414 long int val = astGetL(getRawPtr(), attrib.c_str());
415 assertOK();
416 return val;
417 }

◆ getNColumn()

int ast::Table::getNColumn ( ) const
inlineinherited

Get NColumn: The number of columns currently in the Table.

Definition at line 101 of file Table.h.

101{ return Object::getI("NColumn"); }

◆ getNObject()

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

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 153 of file Object.h.

153{ return getI("NObject"); }

◆ getNRow()

int ast::Table::getNRow ( ) const
inlineinherited

Get NRow: The number of rows currently in the Table.

Definition at line 106 of file Table.h.

106{ return Object::getI("NRow"); }

◆ getObjSize()

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

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

Definition at line 156 of file Object.h.

156{ return getI("ObjSize"); }

◆ getRawPtr() [1/2]

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

Get the raw AST pointer.

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

Definition at line 294 of file Object.h.

294{ return &*_objPtr; };

◆ getRawPtr() [2/2]

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

Get the raw AST pointer.

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

Definition at line 292 of file Object.h.

292{ return &*_objPtr; };

◆ getRefCount()

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

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

Warning
Intended only for debugging astshim.

Definition at line 163 of file Object.h.

163{ return getI("RefCount"); }

◆ getS() [1/2]

std::vector< short int > ast::KeyMap::getS ( std::string const &  key) const
inlineinherited

Get all short int values for a given key.

Definition at line 243 of file KeyMap.h.

243 {
244 int const size = length(key);
246 if (size > 0) {
247 int nret; // should equal size after the call
248 astMapGet1S(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
249 retVec.data());
250 }
251 assertOK();
252 return retVec;
253 }

◆ getS() [2/2]

short int ast::KeyMap::getS ( std::string const &  key,
int  ind 
) const
inlineinherited

Get one short int value for a given key.

Definition at line 233 of file KeyMap.h.

233 {
234 short int retVal;
235 if (!astMapGetElemS(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
236 throwKeyNotFound(key);
237 }
238 assertOK();
239 return retVal;
240 }

◆ getTableHeader()

std::shared_ptr< FitsChan > ast::FitsTable::getTableHeader ( ) const
inline

Definition at line 61 of file FitsTable.h.

61 {
62 auto *rawFitsChan = reinterpret_cast<AstObject *>(astGetTableHeader(getRawPtr()));
63 assertOK(rawFitsChan);
64 if (!rawFitsChan) {
65 throw std::runtime_error("getTableHeader failed (returned a null fitschan)");
66 }
67 return Object::fromAstObject<FitsChan>(rawFitsChan, false);
68 }

◆ getUseDefs()

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

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

Definition at line 166 of file Object.h.

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

◆ hasAttribute()

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

Does this object have an attribute with the specified name?

Definition at line 127 of file Object.h.

127 {
128 bool ret = astHasAttribute(getRawPtr(), attrib.c_str());
129 assertOK();
130 return ret;
131 }

◆ hasKey()

bool ast::KeyMap::hasKey ( std::string const &  key) const
inlineinherited

Does this map contain the specified key?

See also defined, which also checks that the value is defined

Definition at line 142 of file KeyMap.h.

142 {
143 bool ret = static_cast<bool>(
144 astMapHasKey(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str()));
145 assertOK();
146 return ret;
147 }

◆ key()

std::string ast::KeyMap::key ( int  ind) const
inlineinherited

Get the key at the specified index.

Definition at line 125 of file KeyMap.h.

125 {
126 int const len = size();
127 if ((ind < 0) || (ind >= len)) {
129 os << "ind = " << ind << " not in range [0, " << len - 1 << "]";
130 throw std::invalid_argument(os.str());
131 }
132 const char *rawKey = astMapKey(reinterpret_cast<AstKeyMap const *>(getRawPtr()), ind);
133 assertOK();
134 return std::string(rawKey);
135 }

◆ length()

int ast::KeyMap::length ( std::string const &  key) const
inlineinherited

Get the size of the vector for the specified key; return 0 if key not found or value is undefined.

Definition at line 150 of file KeyMap.h.

150 {
151 int len = astMapLength(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str());
152 assertOK();
153 return len;
154 }

◆ lock()

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

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 202 of file Object.h.

202 {
203 astLock(getRawPtr(), static_cast<int>(wait));
204 assertOK();
205 }

◆ makeShim()

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

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 310 of file Object.h.

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

◆ operator!=()

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

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]

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

◆ operator=() [2/2]

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

◆ operator==()

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

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 85 of file Object.cc.

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

◆ putA() [1/2]

void ast::KeyMap::putA ( std::string const &  key,
Object const &  obj,
std::string const &  comment = "" 
)
inlineinherited

Add an Object, which is deep copied.

Definition at line 421 of file KeyMap.h.

421 {
422 AstObject *rawCopy = reinterpret_cast<AstObject *>(astCopy(obj.getRawPtr()));
423 astMapPut0A(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), rawCopy, comment.c_str());
424 assertOK(rawCopy);
425 }

◆ putA() [2/2]

void ast::KeyMap::putA ( std::string const &  key,
std::vector< std::shared_ptr< Object const > > const &  vec,
std::string const &  comment = "" 
)
inlineinherited

Add a vector of shared pointer to Object; the objects are deep copied.

Definition at line 428 of file KeyMap.h.

429 {
430 _assertVectorNotEmpty(key, vec.size());
431 // to simplify memory management, create the key with the first element and append the rest
432 for (int i = 0, size = vec.size(); i < size; ++i) {
433 if (i == 0) {
434 // initialize the key with the first element
435 putA(key, *vec[0]);
436 } else {
437 append(key, *vec[i]);
438 }
439 }
440 }
void append(std::string const &key, double value)
Append an element to a vector of doubles in a KeyMap.
Definition: KeyMap.h:454
void putA(std::string const &key, Object const &obj, std::string const &comment="")
Add an Object, which is deep copied.
Definition: KeyMap.h:421
T size(T... args)

◆ putB() [1/2]

void ast::KeyMap::putB ( std::string const &  key,
char unsigned  value,
std::string const &  comment = "" 
)
inlineinherited

Add a char.

Definition at line 387 of file KeyMap.h.

387 {
388 astMapPut0B(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
389 assertOK();
390 }

◆ putB() [2/2]

void ast::KeyMap::putB ( std::string const &  key,
std::vector< char unsigned > const &  vec,
std::string const &  comment = "" 
)
inlineinherited

Add a vector of chars.

Definition at line 393 of file KeyMap.h.

394 {
395 _assertVectorNotEmpty(key, vec.size());
396 astMapPut1B(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
397 comment.c_str());
398 assertOK();
399 }
T data(T... args)

◆ putC() [1/2]

void ast::KeyMap::putC ( std::string const &  key,
std::string const &  value,
std::string const &  comment = "" 
)
inlineinherited

Add a string.

Definition at line 402 of file KeyMap.h.

402 {
403 astMapPut0C(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value.c_str(), comment.c_str());
404 assertOK();
405 }

◆ putC() [2/2]

void ast::KeyMap::putC ( std::string const &  key,
std::vector< std::string > const &  vec,
std::string const &  comment = "" 
)
inlineinherited

Add a vector of strings.

Definition at line 408 of file KeyMap.h.

408 {
409 _assertVectorNotEmpty(key, vec.size());
410 // to simplify memory management, create the key with the first element and append the rest
411 for (int i = 0, size = vec.size(); i < size; ++i) {
412 if (i == 0) {
413 putC(key, vec[0]);
414 } else {
415 append(key, vec[i]);
416 }
417 }
418 }
void putC(std::string const &key, std::string const &value, std::string const &comment="")
Add a string.
Definition: KeyMap.h:402

◆ putD() [1/2]

void ast::KeyMap::putD ( std::string const &  key,
double  value,
std::string const &  comment = "" 
)
inlineinherited

Add a double value.

Definition at line 331 of file KeyMap.h.

331 {
332 astMapPut0D(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
333 assertOK();
334 }

◆ putD() [2/2]

void ast::KeyMap::putD ( std::string const &  key,
std::vector< double > const &  vec,
std::string const &  comment = "" 
)
inlineinherited

Add a vector of double.

Definition at line 337 of file KeyMap.h.

337 {
338 _assertVectorNotEmpty(key, vec.size());
339 astMapPut1D(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
340 comment.c_str());
341 assertOK();
342 }

◆ putF() [1/2]

void ast::KeyMap::putF ( std::string const &  key,
float  value,
std::string const &  comment = "" 
)
inlineinherited

Add a float.

Definition at line 345 of file KeyMap.h.

345 {
346 astMapPut0F(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
347 assertOK();
348 }

◆ putF() [2/2]

void ast::KeyMap::putF ( std::string const &  key,
std::vector< float > const &  vec,
std::string const &  comment = "" 
)
inlineinherited

Add a vector of floats.

Definition at line 351 of file KeyMap.h.

351 {
352 _assertVectorNotEmpty(key, vec.size());
353 astMapPut1F(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
354 comment.c_str());
355 assertOK();
356 }

◆ putI() [1/2]

void ast::KeyMap::putI ( std::string const &  key,
int  value,
std::string const &  comment = "" 
)
inlineinherited

Add an int.

Definition at line 359 of file KeyMap.h.

359 {
360 astMapPut0I(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
361 assertOK();
362 }

◆ putI() [2/2]

void ast::KeyMap::putI ( std::string const &  key,
std::vector< int > const &  vec,
std::string const &  comment = "" 
)
inlineinherited

Add a vector of ints.

Definition at line 365 of file KeyMap.h.

365 {
366 _assertVectorNotEmpty(key, vec.size());
367 astMapPut1I(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
368 comment.c_str());
369 assertOK();
370 }

◆ putS() [1/2]

void ast::KeyMap::putS ( std::string const &  key,
short int  value,
std::string const &  comment = "" 
)
inlineinherited

Add a short int.

Definition at line 373 of file KeyMap.h.

373 {
374 astMapPut0S(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
375 assertOK();
376 }

◆ putS() [2/2]

void ast::KeyMap::putS ( std::string const &  key,
std::vector< short int > const &  vec,
std::string const &  comment = "" 
)
inlineinherited

Add a vector of short int.

Definition at line 379 of file KeyMap.h.

379 {
380 _assertVectorNotEmpty(key, vec.size());
381 astMapPut1S(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
382 comment.c_str());
383 assertOK();
384 }

◆ putU()

void ast::KeyMap::putU ( std::string const &  key,
std::string const &  comment = "" 
)
inlineinherited

Add a new entry, but no value is stored with the entry.

The entry has a special data type represented by symbolic constant AST__UNDEFTYPE. Such entries can act as placeholders for values that can be added to the KeyMap later.

Definition at line 448 of file KeyMap.h.

448 {
449 astMapPutU(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), comment.c_str());
450 assertOK();
451 }

◆ remove()

void ast::KeyMap::remove ( std::string const &  key)
inlineinherited

Remove the specified entry.

Silently do nothing if this KeyMap does not contain the specified key.

Definition at line 558 of file KeyMap.h.

558 {
559 astMapRemove(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str());
560 assertOK();
561 }

◆ rename()

void ast::KeyMap::rename ( std::string const &  oldKey,
std::string const &  newKey 
)
inlineinherited

Rename the specified entry.

Silently do nothing if this KeyMap does not contain the old key.

Definition at line 568 of file KeyMap.h.

568 {
569 astMapRename(reinterpret_cast<AstKeyMap *>(getRawPtr()), oldKey.c_str(), newKey.c_str());
570 assertOK();
571 }

◆ replace() [1/7]

void ast::KeyMap::replace ( std::string const &  key,
int  i,
char unsigned  value 
)
inlineinherited

Replace an element of a vector of char in a KeyMap.

Definition at line 532 of file KeyMap.h.

532 {
533 _assertReplaceIndexInRange(key, i);
534 astMapPutElemB(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
535 assertOK();
536 }

◆ replace() [2/7]

void ast::KeyMap::replace ( std::string const &  key,
int  i,
double  value 
)
inlineinherited

Replace an element of a vector of doubles in a KeyMap.

Definition at line 504 of file KeyMap.h.

504 {
505 _assertReplaceIndexInRange(key, i);
506 astMapPutElemD(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
507 assertOK();
508 }

◆ replace() [3/7]

void ast::KeyMap::replace ( std::string const &  key,
int  i,
float  value 
)
inlineinherited

Replace an element of a vector of floats in a KeyMap.

Definition at line 511 of file KeyMap.h.

511 {
512 _assertReplaceIndexInRange(key, i);
513 astMapPutElemF(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
514 assertOK();
515 }

◆ replace() [4/7]

void ast::KeyMap::replace ( std::string const &  key,
int  i,
int  value 
)
inlineinherited

Replace an element of a vector of ints in a KeyMap.

Definition at line 518 of file KeyMap.h.

518 {
519 _assertReplaceIndexInRange(key, i);
520 astMapPutElemI(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
521 assertOK();
522 }

◆ replace() [5/7]

void ast::KeyMap::replace ( std::string const &  key,
int  i,
Object const &  value 
)
inlineinherited

Replace an element of a vector of Objects in a KeyMap.

Definition at line 546 of file KeyMap.h.

546 {
547 _assertReplaceIndexInRange(key, i);
548 AstObject *rawCopy = reinterpret_cast<AstObject *>(astCopy(value.getRawPtr()));
549 astMapPutElemA(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, rawCopy);
550 assertOK(rawCopy);
551 }

◆ replace() [6/7]

void ast::KeyMap::replace ( std::string const &  key,
int  i,
short int  value 
)
inlineinherited

Replace an element of a vector of short int in a KeyMap.

Definition at line 525 of file KeyMap.h.

525 {
526 _assertReplaceIndexInRange(key, i);
527 astMapPutElemS(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
528 assertOK();
529 }

◆ replace() [7/7]

void ast::KeyMap::replace ( std::string const &  key,
int  i,
std::string const &  value 
)
inlineinherited

Replace an element of a vector of strings in a KeyMap.

Definition at line 539 of file KeyMap.h.

539 {
540 _assertReplaceIndexInRange(key, i);
541 astMapPutElemC(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value.c_str());
542 assertOK();
543 }

◆ same()

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

Does this contain the same AST object as another?

This is a test of identity, not of equality.

Definition at line 212 of file Object.h.

212{ return astSame(getRawPtr(), other.getRawPtr()); }

◆ set()

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

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 440 of file Object.h.

440 {
441 astSet(getRawPtr(), "%s", setting.c_str());
442 assertOK();
443 }

◆ setB()

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

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 452 of file Object.h.

452 {
453 astSetI(getRawPtr(), attrib.c_str(), value);
454 assertOK();
455 }

◆ setC()

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

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 464 of file Object.h.

464 {
465 astSetC(getRawPtr(), attrib.c_str(), value.c_str());
466 assertOK();
467 }

◆ setD()

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

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 476 of file Object.h.

476 {
477 astSetD(getRawPtr(), attrib.c_str(), value);
478 assertOK();
479 }

◆ setF()

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

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 488 of file Object.h.

488 {
489 astSetF(getRawPtr(), attrib.c_str(), value);
490 assertOK();
491 }

◆ setI()

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

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 500 of file Object.h.

500 {
501 astSetI(getRawPtr(), attrib.c_str(), value);
502 assertOK();
503 }

◆ setID()

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

Set ID: object identification string that is not copied.

Definition at line 215 of file Object.h.

215{ 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:464

◆ setIdent()

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

Set Ident: object identification string that is copied.

Definition at line 218 of file Object.h.

218{ setC("Ident", ident); }

◆ setL()

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

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 512 of file Object.h.

512 {
513 astSetL(getRawPtr(), attrib.c_str(), value);
514 assertOK();
515 }

◆ setUseDefs()

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

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

Definition at line 221 of file Object.h.

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

◆ show() [1/2]

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

Return a textual description the object as a string.

Parameters
[in]showCommentsShow comments?

Definition at line 165 of file Object.cc.

165 {
167 show(os, showComments);
168 return os.str();
169}

◆ show() [2/2]

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

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 158 of file Object.cc.

158 {
159 Stream stream(nullptr, &os);
160 Channel ch(stream, showComments ? "" : "Comment=0");
161 ch.write(*this);
162 assertOK();
163}

◆ size()

int ast::KeyMap::size ( ) const
inlineinherited

Get the number of keys.

Definition at line 157 of file KeyMap.h.

157 {
158 int const size = astMapSize(reinterpret_cast<AstKeyMap const *>(getRawPtr()));
159 assertOK();
160 return size;
161 }

◆ test()

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

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 250 of file Object.h.

250 {
251 bool res = astTest(getRawPtr(), attrib.c_str());
252 assertOK();
253 return res;
254 }

◆ type()

DataType ast::KeyMap::type ( std::string const &  key)
inlineinherited

Get the type suffix for a given key.

Definition at line 576 of file KeyMap.h.

576 {
577 int retVal = astMapType(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str());
578 assertOK();
579 return static_cast<DataType>(retVal);
580 }

◆ unlock()

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

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 280 of file Object.h.

280 {
281 astUnlock(getRawPtr(), static_cast<int>(report));
282 assertOK();
283 }

Friends And Related Function Documentation

◆ Object

friend class Object
friend

Definition at line 39 of file FitsTable.h.


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