LSSTApplications
18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
LSSTDataManagementBasePackage
|
KeyMap is used to store a set of values with associated keys which identify the values. More...
#include <KeyMap.h>
Public Types | |
using | ObjectPtr = std::unique_ptr< AstObject, Deleter > |
unique pointer holding an AST raw pointer More... | |
Public Member Functions | |
KeyMap (std::string const &options="") | |
Construct an empty KeyMap. More... | |
virtual | ~KeyMap () |
KeyMap (KeyMap const &)=default | |
Copy constructor: make a deep copy. More... | |
KeyMap (KeyMap &&)=default | |
KeyMap & | operator= (KeyMap const &)=delete |
KeyMap & | operator= (KeyMap &&)=default |
std::shared_ptr< KeyMap > | copy () 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::string > | getC (std::string const &key) const |
Get all std::string values for a given key. More... | |
std::shared_ptr< Object > | getA (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< Object > | fromString (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 | |
virtual std::shared_ptr< Object > | copyPolymorphic () const override |
Return a deep copy of this object. More... | |
KeyMap (AstKeyMap *rawKeyMap) | |
Construct a KeyMap from a raw AstKeyMap. 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 |
class | Channel |
KeyMap is used to store a set of values with associated keys which identify the values.
The keys are strings. These may be case sensitive or insensitive as selected by the KeyCase attribute, and trailing spaces are ignored. Each key is associated a vector of values of a particular type, which is one of the following, where the single letter is the suffix for the associated setter or getter, such as getD, putD or replaceD:
Despite the name, KeyMap is not a Mapping.
The getters will attempt to cast the data into the requested form. The setters come in three forms:
astMapPutElem<X>
astMapPutElem<X>
)KeyMap has the following attributes, in addition to those inherited from Object
|
inherited |
|
inlineexplicit |
Construct an empty KeyMap.
[in] | options | Comma-separated list of attribute assignments. |
Definition at line 93 of file KeyMap.h.
|
default |
Copy constructor: make a deep copy.
|
default |
|
inlineexplicitprotected |
Construct a KeyMap from a raw AstKeyMap.
Definition at line 591 of file KeyMap.h.
|
inline |
Append an element to a vector of doubles in a KeyMap.
Definition at line 454 of file KeyMap.h.
|
inline |
Append an element to a vector of floats in a KeyMap.
Definition at line 461 of file KeyMap.h.
|
inline |
Append an element to a vector of ints in a KeyMap.
Definition at line 468 of file KeyMap.h.
|
inline |
Append an element to a vector of short int in a KeyMap.
Definition at line 475 of file KeyMap.h.
|
inline |
Append an element to a vector of char in a KeyMap.
Definition at line 482 of file KeyMap.h.
|
inline |
Append an element to a vector of strings in a KeyMap.
Definition at line 489 of file KeyMap.h.
|
inline |
Append an element to a vector of Objects in a KeyMap.
Definition at line 496 of file KeyMap.h.
|
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.
|
inline |
Return a deep copy of this object.
Definition at line 107 of file KeyMap.h.
|
inlineprotectedinherited |
Implementation of deep copy.
Should be called to implement copyPolymorphic by all derived classes.
Definition at line 320 of file Object.h.
|
inlineoverrideprotectedvirtual |
Return a deep copy of this object.
This is called by copy.
Each subclass must override this method. The standard implementation is:
for example Frame implements this as:
Implements ast::Object.
Definition at line 584 of file KeyMap.h.
|
inline |
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.
|
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.
Class | The class of the returned shared pointer. (The actual class will be the correct class of rawPtr.) |
[in] | rawObj | A bare AST object pointer |
[in] | copy | If True then make a deep copy of the pointer (and free the original) |
Definition at line 138 of file Object.cc.
|
inlinestaticinherited |
Construct an Object from a string, using astFromString.
Definition at line 88 of file Object.h.
|
inline |
Get one Object for a given key; the object is deep copied.
Definition at line 310 of file KeyMap.h.
|
inline |
Get all Objects for a given key; each object is deep copied.
Definition at line 321 of file KeyMap.h.
|
inline |
Get one char value for a given key.
Definition at line 256 of file KeyMap.h.
|
inline |
Get all char values for a given key.
Definition at line 266 of file KeyMap.h.
|
inline |
Get one std::string value for a given key.
Definition at line 279 of file KeyMap.h.
|
inline |
Get all std::string values for a given key.
Definition at line 291 of file KeyMap.h.
|
inlineinherited |
Get Class: the name of the class (e.g.
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.
|
inline |
Get one double value for a given key.
Definition at line 164 of file KeyMap.h.
|
inline |
Get all double values for a given key.
Definition at line 174 of file KeyMap.h.
|
inline |
Get one float value for a given key.
Definition at line 187 of file KeyMap.h.
|
inline |
Get all float values for a given key.
Definition at line 197 of file KeyMap.h.
|
inline |
Get one int value for a given key.
Definition at line 210 of file KeyMap.h.
|
inline |
Get all int values for a given key.
Definition at line 220 of file KeyMap.h.
|
inlineinherited |
Get ID: object identification string that is not copied.
Definition at line 142 of file Object.h.
|
inlineinherited |
Get Ident: object identification string that is copied.
Definition at line 145 of file Object.h.
|
inlineprotectedinherited |
Get the value of an attribute as a long int.
If possible, the attribute value is converted to the type you request.
std::runtime_error | if the attribute does not exist or the value cannot be converted |
Definition at line 413 of file Object.h.
|
inlineinherited |
Get NObject: number of AST objects in existence of the same type as the underlying AST class.
Definition at line 153 of file Object.h.
|
inlineinherited |
Get ObjSize: the in-memory size of the AST object in bytes.
Definition at line 156 of file Object.h.
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
Get RefCount: number of active pointers to the underlying AST object.
Definition at line 163 of file Object.h.
|
inline |
Get one short int value for a given key.
Definition at line 233 of file KeyMap.h.
|
inline |
Get all short int values for a given key.
Definition at line 243 of file KeyMap.h.
|
inlineinherited |
Get UseDefs: allow use of default values for Object attributes?
Definition at line 166 of file Object.h.
|
inlineinherited |
Does this object have an attribute with the specified name?
Definition at line 127 of file Object.h.
|
inline |
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.
|
inline |
Get the key at the specified index.
Definition at line 125 of file KeyMap.h.
|
inline |
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.
|
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.
[in] | wait | If 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. |
Definition at line 202 of file Object.h.
|
inlinestaticprotectedinherited |
Functor to make an astshim instance from a raw AST pointer of the corresponding type.
ShimT | Output astshim class |
AstT | Output AST class |
|
inlineinherited |
|
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.
|
inline |
Add an Object, which is deep copied.
Definition at line 421 of file KeyMap.h.
|
inline |
Add a vector of shared pointer to Object; the objects are deep copied.
Definition at line 428 of file KeyMap.h.
|
inline |
Add a char.
Definition at line 387 of file KeyMap.h.
|
inline |
Add a vector of chars.
Definition at line 393 of file KeyMap.h.
|
inline |
Add a string.
Definition at line 402 of file KeyMap.h.
|
inline |
Add a vector of strings.
Definition at line 408 of file KeyMap.h.
|
inline |
Add a double value.
Definition at line 331 of file KeyMap.h.
|
inline |
Add a vector of double.
Definition at line 337 of file KeyMap.h.
|
inline |
Add a float.
Definition at line 345 of file KeyMap.h.
|
inline |
Add a vector of floats.
Definition at line 351 of file KeyMap.h.
|
inline |
Add an int.
Definition at line 359 of file KeyMap.h.
|
inline |
Add a vector of ints.
Definition at line 365 of file KeyMap.h.
|
inline |
Add a short int.
Definition at line 373 of file KeyMap.h.
|
inline |
Add a vector of short int.
Definition at line 379 of file KeyMap.h.
|
inline |
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.
|
inline |
Remove the specified entry.
Silently do nothing if this KeyMap does not contain the specified key.
Definition at line 558 of file KeyMap.h.
|
inline |
Rename the specified entry.
Silently do nothing if this KeyMap does not contain the old key.
Definition at line 568 of file KeyMap.h.
|
inline |
Replace an element of a vector of doubles in a KeyMap.
Definition at line 504 of file KeyMap.h.
|
inline |
Replace an element of a vector of floats in a KeyMap.
Definition at line 511 of file KeyMap.h.
|
inline |
Replace an element of a vector of ints in a KeyMap.
Definition at line 518 of file KeyMap.h.
|
inline |
Replace an element of a vector of short int in a KeyMap.
Definition at line 525 of file KeyMap.h.
|
inline |
Replace an element of a vector of char in a KeyMap.
Definition at line 532 of file KeyMap.h.
|
inline |
Replace an element of a vector of strings in a KeyMap.
Definition at line 539 of file KeyMap.h.
|
inline |
Replace an element of a vector of Objects in a KeyMap.
Definition at line 546 of file KeyMap.h.
|
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.
|
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.
std::runtime_error | if the attribute is read-only |
Definition at line 440 of file Object.h.
|
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.
std::runtime_error | if the attribute does not exist or the value cannot be converted |
Definition at line 452 of file Object.h.
|
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.
std::runtime_error | if the attribute does not exist or the value cannot be converted |
Definition at line 464 of file Object.h.
|
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.
std::runtime_error | if the attribute does not exist or the value cannot be converted |
Definition at line 476 of file Object.h.
|
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.
std::runtime_error | if the attribute does not exist or the value cannot be converted |
Definition at line 488 of file Object.h.
|
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.
std::runtime_error | if the attribute does not exist or the value cannot be converted |
Definition at line 500 of file Object.h.
|
inlineinherited |
Set ID: object identification string that is not copied.
Definition at line 215 of file Object.h.
|
inlineinherited |
Set Ident: object identification string that is copied.
Definition at line 218 of file Object.h.
|
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.
std::runtime_error | if the attribute does not exist or the value cannot be converted |
Definition at line 512 of file Object.h.
|
inlineinherited |
Set UseDefs: allow use of default values for Object attributes?
Definition at line 221 of file Object.h.
|
inherited |
Print a textual description the object to an ostream.
[in,out] | os | The stream to which to write the string representation. |
[in] | showComments | Show comments? |
Definition at line 158 of file Object.cc.
|
inherited |
Return a textual description the object as a string.
[in] | showComments | Show comments? |
Definition at line 165 of file Object.cc.
|
inline |
Get the number of keys.
Definition at line 157 of file KeyMap.h.
|
inlineinherited |
Has this attribute been explicitly set (and not subsequently cleared)?
false
.std::runtime_error | if an error results. |
Definition at line 250 of file Object.h.
|
inline |
Get the type suffix for a given key.
Definition at line 576 of file KeyMap.h.
|
inlineinherited |
Unlock this object previously locked using lock, so that other threads can use this object.
See lock for further details.
[in] | report | If 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. |
Definition at line 280 of file Object.h.