LSST Applications g0f08755f38+9c285cab97,g1635faa6d4+13f3999e92,g1653933729+a8ce1bb630,g1a0ca8cf93+bf6eb00ceb,g28da252d5a+0829b12dee,g29321ee8c0+5700dc9eac,g2bbee38e9b+9634bc57db,g2bc492864f+9634bc57db,g2cdde0e794+c2c89b37c4,g3156d2b45e+41e33cbcdc,g347aa1857d+9634bc57db,g35bb328faa+a8ce1bb630,g3a166c0a6a+9634bc57db,g3e281a1b8c+9f2c4e2fc3,g414038480c+077ccc18e7,g41af890bb2+fde0dd39b6,g5fbc88fb19+17cd334064,g781aacb6e4+a8ce1bb630,g80478fca09+55a9465950,g82479be7b0+d730eedb7d,g858d7b2824+9c285cab97,g9125e01d80+a8ce1bb630,g9726552aa6+10f999ec6a,ga5288a1d22+2a84bb7594,gacf8899fa4+c69c5206e8,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc28159a63d+9634bc57db,gcf0d15dbbd+4b7d09cae4,gda3e153d99+9c285cab97,gda6a2b7d83+4b7d09cae4,gdaeeff99f8+1711a396fd,ge2409df99d+5e831397f4,ge79ae78c31+9634bc57db,gf0baf85859+147a0692ba,gf3967379c6+41c94011de,gf3fb38a9a8+8f07a9901b,gfb92a5be7c+9c285cab97,w.2024.46
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. | |
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. | |
template<typename F > | |
void | findAndApply (std::string const &name, F &&func) const |
Find a nested SchemaItem by name and run a functor on it. | |
template<typename F > | |
void | apply (F &&func) const |
Run functor on the SchemaItem represented by this SubSchema. | |
SubSchema | operator[] (std::string const &name) const |
Return a nested proxy. | |
std::string const & | getPrefix () const |
Return the prefix that defines this SubSchema relative to its parent Schema. | |
std::set< std::string > | getNames (bool topOnly=false) const |
Return a set of nested names that start with the SubSchema's prefix. | |
template<typename T > | |
operator Key< T > () const | |
Implicit conversion to the appropriate Key type. | |
template<typename T > | |
operator Field< T > () const | |
Implicit conversion to the appropriate Key type. | |
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());
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 |
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 asField() method.
|
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 |