LSST Applications 27.0.0,g0265f82a02+469cd937ee,g02d81e74bb+21ad69e7e1,g1470d8bcf6+cbe83ee85a,g2079a07aa2+e67c6346a6,g212a7c68fe+04a9158687,g2305ad1205+94392ce272,g295015adf3+81dd352a9d,g2bbee38e9b+469cd937ee,g337abbeb29+469cd937ee,g3939d97d7f+72a9f7b576,g487adcacf7+71499e7cba,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+df404f777f,g5a732f18d5+be83d3ecdb,g64a986408d+21ad69e7e1,g858d7b2824+21ad69e7e1,g8a8a8dda67+a6fc98d2e7,g99cad8db69+f62e5b0af5,g9ddcbc5298+d4bad12328,ga1e77700b3+9c366c4306,ga8c6da7877+71e4819109,gb0e22166c9+25ba2f69a1,gb6a65358fc+469cd937ee,gbb8dafda3b+69d3c0e320,gc07e1c2157+a98bf949bb,gc120e1dc64+615ec43309,gc28159a63d+469cd937ee,gcf0d15dbbd+72a9f7b576,gdaeeff99f8+a38ce5ea23,ge6526c86ff+3a7c1ac5f1,ge79ae78c31+469cd937ee,gee10cc3b42+a6fc98d2e7,gf1cff7945b+21ad69e7e1,gfbcc870c63+9a11dc8c8f
LSST Data Management Base Package
|
Channel provides input/output of AST objects. More...
#include <Channel.h>
Public Types | |
using | ObjectPtr = std::unique_ptr<AstObject, Deleter> |
unique pointer holding an AST raw pointer | |
Public Member Functions | |
Channel (Stream &stream, std::string const &options="") | |
Construct a channel that uses a provided Stream. | |
virtual | ~Channel () |
Channel (Channel const &)=delete | |
Channel (Channel &&)=default | |
Channel & | operator= (Channel const &)=delete |
Channel & | operator= (Channel &&)=default |
std::shared_ptr< Channel > | copy () const |
Return a deep copy of this object. | |
bool | getComment () const |
Get Comment: include textual comments in output? | |
int | getFull () const |
Get Full: level of output detail; one of -1: minimum, 0: normal, 1: verbose. | |
int | getIndent () const |
Get Indent: indentation increment between objects. | |
int | getReportLevel () const |
Get ReportLevel: report level. | |
bool | getSkip () const |
Get Skip: skip irrelevant data on input? | |
bool | getStrict () const |
Get Strict: generate errors instead of warnings? | |
std::shared_ptr< Object > | read () |
Read an object from a channel. | |
void | setComment (bool skip) |
Set Comment: include textual comments in output? | |
void | setFull (int full) |
Set Full: level of output detail; one of -1: minimum, 0: normal, 1: verbose. | |
void | setIndent (int indent) |
Set Indent: indentation increment between objects. | |
void | setReportLevel (int level) |
Set ReportLevel: report level; an integer in the range [0, 3] where 0 is the most verbose. | |
void | setSkip (bool skip) |
Set Skip: skip irrelevant data on input? | |
void | setStrict (bool strict) |
Set Strict: generate errors instead of warnings? | |
KeyMap | warnings () const |
Return a KeyMap holding the text of any warnings issued as a result of the previous invocation of read or write. | |
int | write (Object const &object) |
Write an object to a channel. | |
bool | operator== (Object const &rhs) const |
Return True if this and rhs are the equal. | |
bool | operator!= (Object const &rhs) const |
Return True if this and rhs are not equal. | |
void | clear (std::string const &attrib) |
Clear the values of a specified set of attributes for an Object. | |
bool | hasAttribute (std::string const &attrib) const |
Does this object have an attribute with the specified name? | |
std::string | getClassName () const |
Get Class: the name of the class (e.g. | |
std::string | getID () const |
Get ID: object identification string that is not copied. | |
std::string | getIdent () const |
Get Ident: object identification string that is copied. | |
int | getNObject () const |
Get NObject: number of AST objects in existence of the same type as the underlying AST class. | |
int | getObjSize () const |
Get ObjSize: the in-memory size of the AST object in bytes. | |
int | getRefCount () const |
Get RefCount: number of active pointers to the underlying AST object. | |
bool | getUseDefs () const |
Get UseDefs: allow use of default values for Object attributes? | |
void | lock (bool wait) |
Lock this object for exclusive use by the calling thread. | |
bool | same (Object const &other) const |
Does this contain the same AST object as another? | |
void | setID (std::string const &id) |
Set ID: object identification string that is not copied. | |
void | setIdent (std::string const &ident) |
Set Ident: object identification string that is copied. | |
void | setUseDefs (bool usedefs) |
Set UseDefs: allow use of default values for Object attributes? | |
void | show (std::ostream &os, bool showComments=true) const |
Print a textual description the object to an ostream. | |
std::string | show (bool showComments=true) const |
Return a textual description the object as a string. | |
bool | test (std::string const &attrib) const |
Has this attribute been explicitly set (and not subsequently cleared)? | |
void | unlock (bool report=false) |
Unlock this object previously locked using lock, so that other threads can use this object. | |
AstObject const * | getRawPtr () const |
Get the raw AST pointer. | |
AstObject * | getRawPtr () |
Get the raw AST pointer. | |
Static Public Member Functions | |
static std::shared_ptr< Object > | fromString (std::string const &str) |
Construct an Object from a string, using astFromString. | |
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. | |
Protected Member Functions | |
virtual std::shared_ptr< Object > | copyPolymorphic () const override |
Return a deep copy of this object. | |
Channel (AstChannel *chan, Stream &stream, bool isFits=false) | |
Construct a channel from an AST channel pointer and a Stream. | |
Channel (AstChannel *chan) | |
Construct a channel from an AST channel pointer that has its own stream. | |
template<typename T , typename AstT > | |
std::shared_ptr< T > | copyImpl () const |
Implementation of deep copy. | |
bool | getB (std::string const &attrib) const |
Get the value of an attribute as a bool. | |
std::string const | getC (std::string const &attrib) const |
Get the value of an attribute as a string. | |
double | getD (std::string const &attrib) const |
Get the value of an attribute as a double. | |
float | getF (std::string const &attrib) const |
Get the value of an attribute as a float. | |
int | getI (std::string const &attrib) const |
Get the value of an attribute as an int. | |
long int | getL (std::string const &attrib) const |
Get the value of an attribute as a long int. | |
void | set (std::string const &setting) |
Assign a set of attribute values, over-riding any previous values. | |
void | setB (std::string const &attrib, bool value) |
Set the value of an attribute as a bool. | |
void | setC (std::string const &attrib, std::string const &value) |
Set the value of an attribute as a string. | |
void | setD (std::string const &attrib, double value) |
Set the value of an attribute as a double. | |
void | setF (std::string const &attrib, float value) |
Set the value of an attribute as a float. | |
void | setI (std::string const &attrib, int value) |
Set the value of an attribute as an int. | |
void | setL (std::string const &attrib, long int value) |
Set the value of an attribute as a long int. | |
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. | |
Friends | |
class | Object |
Channel provides input/output of AST objects.
Writing an Object to a Channel will generate a textual representation of that Object, and reading from a Channel will create a new Object from its textual representation.
Note that a channel cannot be deep-copied because the contained stream cannot be deep-copied
Channel provides the following attributes, in addition to those provided by Object
|
inherited |
|
explicit |
Construct a channel that uses a provided Stream.
[in] | stream | Stream for channel I/O:
|
[in] | options | Comma-separated list of attribute assignments. |
Definition at line 31 of file Channel.cc.
|
virtual |
Definition at line 45 of file Channel.cc.
|
delete |
|
default |
|
explicitprotected |
Construct a channel from an AST channel pointer and a Stream.
This is the constructor most subclasses use for their high-level constructor.
[in] | chan | AstChannel object |
[in,out] | stream | Stream to associate with the channel |
[in] | isFits | If true then read or write the stream as a FITS header |
Definition at line 36 of file Channel.cc.
|
explicitprotected |
Construct a channel from an AST channel pointer that has its own stream.
[in] | chan | AstChannel object |
Definition at line 43 of file Channel.cc.
|
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.
|
inline |
|
inlineprotectedinherited |
|
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 159 of file Channel.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 |
|
inlineprotectedinherited |
Get the value of an attribute as a bool.
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 |
|
inlineprotectedinherited |
Get the value of an attribute as a string.
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 |
|
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 Comment: include textual comments in output?
Definition at line 90 of file Channel.h.
|
inlineprotectedinherited |
Get the value of an attribute as a double.
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 |
|
inlineprotectedinherited |
Get the value of an attribute as a float.
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 |
|
inline |
Get Full: level of output detail; one of -1: minimum, 0: normal, 1: verbose.
Definition at line 93 of file Channel.h.
|
protectedinherited |
Get the value of an attribute as an 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 |
|
inlineinherited |
Get ID: object identification string that is not copied.
Definition at line 142 of file Object.h.
|
inlineinherited |
|
inline |
|
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 |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inline |
|
inline |
|
inline |
|
inlineinherited |
|
inlineinherited |
|
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. |
|
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.
std::shared_ptr< Object > ast::Channel::read | ( | ) |
Read an object from a channel.
Definition at line 52 of file Channel.cc.
|
inlineinherited |
|
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 |
|
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 |
|
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 |
|
inline |
Set Comment: include textual comments in output?
Definition at line 111 of file Channel.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 |
|
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 |
|
inline |
Set Full: level of output detail; one of -1: minimum, 0: normal, 1: verbose.
Definition at line 114 of file Channel.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 |
|
inlineinherited |
Set ID: object identification string that is not copied.
Definition at line 215 of file Object.h.
|
inlineinherited |
|
inline |
|
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 |
|
inline |
Set ReportLevel: report level; an integer in the range [0, 3] where 0 is the most verbose.
std::invalid_argument | if level is not in range [0, 3] |
Definition at line 125 of file Channel.h.
|
inline |
|
inline |
|
inlineinherited |
|
inherited |
Return a textual description the object as a string.
[in] | showComments | Show comments? |
|
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.
|
inlineinherited |
Has this attribute been explicitly set (and not subsequently cleared)?
false
.std::runtime_error | if an error results. |
|
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. |
KeyMap ast::Channel::warnings | ( | ) | const |
Return a KeyMap holding the text of any warnings issued as a result of the previous invocation of read or write.
If no warnings were issued, an empty KeyMap will be returned. Such warnings are non-fatal and will not prevent the read or write operation succeeding. However, the converted object may not be identical to the original object in all respects. Differences which would usually be deemed as insignificant in most usual cases will generate a warning, whereas more significant differences will generate an error.
The " Strict" attribute allows this warning facility to be switched off, so that a fatal error is always reported for any conversion error.
Definition at line 67 of file Channel.cc.
int ast::Channel::write | ( | Object const & | object | ) |
Write an object to a channel.
Definition at line 61 of file Channel.cc.