LSST Applications
21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
|
A proxy type for name lookups in a Schema. More...
#include <Schema.h>
Public Member Functions | |
std::string | join (std::string const &a, std::string const &b) const |
Join strings using the field delimiter appropriate for this Schema. More... | |
std::string | join (std::string const &a, std::string const &b, std::string const &c) const |
std::string | join (std::string const &a, std::string const &b, std::string const &c, std::string const &d) const |
template<typename T > | |
SchemaItem< T > | find (std::string const &name) const |
Find a nested SchemaItem by name. More... | |
template<typename F > | |
void | findAndApply (std::string const &name, F &&func) const |
Find a nested SchemaItem by name and run a functor on it. More... | |
template<typename F > | |
void | apply (F &&func) const |
Run functor on the SchemaItem represented by this SubSchema. More... | |
SubSchema | operator[] (std::string const &name) const |
Return a nested proxy. More... | |
std::string const & | getPrefix () const |
Return the prefix that defines this SubSchema relative to its parent Schema. More... | |
std::set< std::string > | getNames (bool topOnly=false) const |
Return a set of nested names that start with the SubSchema's prefix. More... | |
template<typename T > | |
operator Key< T > () const | |
Implicit conversion to the appropriate Key type. More... | |
template<typename T > | |
operator Field< T > () const | |
Implicit conversion to the appropriate Key type. More... | |
Friends | |
class | Schema |
A proxy type for name lookups in a Schema.
Elements of schema names are assumed to be separated by underscores ("a_b_c"); an incomplete lookup is one that does not resolve to a field. Not that even complete lookups can have nested names; a Point field, for instance, has "x" and "y" nested names.
This proxy object is implicitly convertible to both the appropriate Key type and the appropriate Field type, if the name is a complete one, and supports additional find() operations for nested names.
SubSchema is implemented as a proxy that essentially calls Schema::find after concatenating strings. It does not provide any performance advantage over using Schema::find directly. It is also lazy, so looking up a name prefix that does not exist within the schema is not considered an error until the proxy is used.
Some examples:
Schema schema(false); Key<int> a_i = schema.addField<int>("a_i", "integer field"); Key< Point<double> > a_p = schema.addField< Point<double> >("a_p", "point field"); assert(schema["a_i"] == a_i); SubSchema a = schema["a"]; assert(a["i"] == a_i); Field<int> f_a_i = schema["a_i"]; assert(f_a_i.getDoc() == "integer field"); assert(schema["a_i"] == "a_i"); assert(schema.find("a_p_x") == a_p.getX());
|
inline |
Run functor on the SchemaItem represented by this SubSchema.
The given functor must have an overloaded function call operator that accepts any SchemaItem type (the same as a functor provided to apply or Schema::forEach).
Throws | pex::exceptions::NotFoundError if the SubSchemas prefix does not correspond to the full name of a regular field (not a named subfield). |
Definition at line 412 of file Schema.h.
SchemaItem< T > lsst::afw::table::SubSchema::find | ( | std::string const & | name | ) | const |
Find a nested SchemaItem by name.
Definition at line 584 of file Schema.cc.
|
inline |
Find a nested SchemaItem by name and run a functor on it.
Names corresponding to named subfields are not accepted. The given functor must have an overloaded function call operator that accepts any SchemaItem type (the same as a functor provided to apply or Schema::forEach).
std::set< std::string > lsst::afw::table::SubSchema::getNames | ( | bool | topOnly = false | ) | const |
Return a set of nested names that start with the SubSchema's prefix.
Returns an instance of Python's builtin set in Python.
Definition at line 592 of file Schema.cc.
|
inline |
std::string lsst::afw::table::SubSchema::join | ( | std::string const & | a, |
std::string const & | b | ||
) | const |
|
inline |
|
inline |
|
inline |
|
inline |
Implicit conversion to the appropriate Key type.
Implicit conversion operators that are invoked via assignment cannot be translated to Python. Instead, the Python wrappers provide an equivalent asKey() method.
SubSchema lsst::afw::table::SubSchema::operator[] | ( | std::string const & | name | ) | const |