lsst.astshim  20.0.0
Public Member Functions | Protected Member Functions | Friends | List of all members
ast::KeyMap Class Reference

#include <KeyMap.h>

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

Public Member Functions

 KeyMap (std::string const &options="")
 
virtual ~KeyMap ()
 
 KeyMap (KeyMap const &)=default
 Copy constructor: make a deep copy. More...
 
 KeyMap (KeyMap &&)=default
 
KeyMapoperator= (KeyMap const &)=delete
 
KeyMapoperator= (KeyMap &&)=default
 
std::shared_ptr< KeyMapcopy () const
 Return a deep copy of this object. More...
 
bool defined (std::string const &key) const
 
std::string key (int ind) const
 Get the key at the specified index. More...
 
bool hasKey (std::string const &key) const
 
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< 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="")
 
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)
 
void rename (std::string const &oldKey, std::string const &newKey)
 
DataType type (std::string const &key)
 
- Public Member Functions inherited from ast::Object
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 ()
 

Protected Member Functions

virtual std::shared_ptr< ObjectcopyPolymorphic () const override
 
 KeyMap (AstKeyMap *rawKeyMap)
 
- Protected Member Functions inherited from ast::Object
 Object (AstObject *object)
 
template<typename T , typename AstT >
std::shared_ptr< T > copyImpl () const
 
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)
 

Friends

class Object
 
class Channel
 

Additional Inherited Members

- Public Types inherited from ast::Object
using ObjectPtr = std::unique_ptr< AstObject, Deleter >
 unique pointer holding an AST raw pointer More...
 
- Static Public Member Functions inherited from ast::Object
static std::shared_ptr< ObjectfromString (std::string const &str)
 
template<typename Class >
static std::shared_ptr< Class > fromAstObject (AstObject *rawObj, bool copy)
 
- Static Protected Member Functions inherited from ast::Object
template<typename ShimT , typename AstT >
static std::shared_ptr< ShimT > makeShim (AstObject *p)
 

Detailed Description

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:

Attributes

KeyMap has the following attributes, in addition to those inherited from Object

Constructor & Destructor Documentation

◆ KeyMap() [1/4]

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

Construct an empty KeyMap

Parameters
[in]optionsComma-separated list of attribute assignments.

◆ ~KeyMap()

virtual ast::KeyMap::~KeyMap ( )
inlinevirtual

◆ KeyMap() [2/4]

ast::KeyMap::KeyMap ( KeyMap const &  )
default

Copy constructor: make a deep copy.

◆ KeyMap() [3/4]

ast::KeyMap::KeyMap ( KeyMap &&  )
default

◆ KeyMap() [4/4]

ast::KeyMap::KeyMap ( AstKeyMap *  rawKeyMap)
inlineexplicitprotected

Construct a KeyMap from a raw AstKeyMap

Member Function Documentation

◆ append() [1/7]

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

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

◆ append() [2/7]

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

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

◆ append() [3/7]

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

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

◆ append() [4/7]

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

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

◆ append() [5/7]

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

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

◆ append() [6/7]

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

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

◆ append() [7/7]

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

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

◆ copy()

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

Return a deep copy of this object.

◆ copyPolymorphic()

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

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.

◆ defined()

bool ast::KeyMap::defined ( std::string const &  key) const
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

◆ getA() [1/2]

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

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

◆ getA() [2/2]

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

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

◆ getB() [1/2]

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

Get all char values for a given key.

◆ getB() [2/2]

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

Get one char value for a given key.

◆ getC() [1/2]

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

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

◆ getC() [2/2]

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

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

◆ getD() [1/2]

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

Get all double values for a given key.

◆ getD() [2/2]

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

Get one double value for a given key.

◆ getF() [1/2]

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

Get all float values for a given key.

◆ getF() [2/2]

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

Get one float value for a given key.

◆ getI() [1/2]

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

Get all int values for a given key.

◆ getI() [2/2]

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

Get one int value for a given key.

◆ getS() [1/2]

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

Get all short int values for a given key.

◆ getS() [2/2]

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

Get one short int value for a given key.

◆ hasKey()

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

Does this map contain the specified key?

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

◆ key()

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

Get the key at the specified index.

◆ length()

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

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

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ putA() [1/2]

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

Add an Object, which is deep copied.

◆ putA() [2/2]

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

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

◆ putB() [1/2]

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

Add a char.

◆ putB() [2/2]

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

Add a vector of chars.

◆ putC() [1/2]

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

Add a string.

◆ putC() [2/2]

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

Add a vector of strings.

◆ putD() [1/2]

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

Add a double value.

◆ putD() [2/2]

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

Add a vector of double.

◆ putF() [1/2]

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

Add a float.

◆ putF() [2/2]

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

Add a vector of floats.

◆ putI() [1/2]

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

Add an int.

◆ putI() [2/2]

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

Add a vector of ints.

◆ putS() [1/2]

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

Add a short int.

◆ putS() [2/2]

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

Add a vector of short int.

◆ putU()

void ast::KeyMap::putU ( std::string const &  key,
std::string const &  comment = "" 
)
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.

◆ remove()

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

Remove the specified entry.

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

◆ rename()

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

Rename the specified entry.

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

◆ replace() [1/7]

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

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

◆ replace() [2/7]

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

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

◆ replace() [3/7]

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

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

◆ replace() [4/7]

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

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

◆ replace() [5/7]

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

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

◆ replace() [6/7]

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

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

◆ replace() [7/7]

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

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

◆ size()

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

Get the number of keys.

◆ type()

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

Get the type suffix for a given key

Friends And Related Function Documentation

◆ Channel

friend class Channel
friend

◆ Object

friend class Object
friend

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