LSSTApplications
19.0.0-14-gb0260a2+2d714fc2ef,20.0.0+34a42eae2c,20.0.0+76f397ef0c,20.0.0+8558dd3f48,20.0.0+a6b6977b51,20.0.0+b2ea66fa67,20.0.0+cc669a8b45,20.0.0+d561663fb5,20.0.0+d778e99126,20.0.0+efe67588cf,20.0.0+f45b7d88f4,20.0.0+f7c597f720,20.0.0+fb43bee9b9,20.0.0+fb4d547e0d,20.0.0-1-g10df615+d8b88ec1b5,20.0.0-1-g253301a+a6b6977b51,20.0.0-1-g498fb60+ff88705a28,20.0.0-1-g4d801e7+ce0d01dabd,20.0.0-1-g5b95a8c+24eaf908b3,20.0.0-1-g8a53f90+2817c06967,20.0.0-1-gc96f8cb+fb4d547e0d,20.0.0-1-gd1c87d7+2817c06967,20.0.0-1-gdb27ee5+abab67204f,20.0.0-13-ge998c5c+9f8c516ffa,20.0.0-18-g08fba245+88079d2923,20.0.0-2-gec03fae+fb98bf9d97,20.0.0-3-gdd5c15c+a61313b210,20.0.0-34-gdb4d86a+b43b2c05ff,20.0.0-4-g4a2362f+f45b7d88f4,20.0.0-4-gfea843c+f45b7d88f4,20.0.0-5-gac0d578b1+a8c4e2ada3,20.0.0-5-gfcebe35+cfceff6a24,20.0.0-6-g01203fff+e332440eaf,20.0.0-8-gea2affd+48c001ce3c,20.0.0-9-gabd0d4c+abab67204f,20.0.0-9-gf3ab18e+fb4d547e0d,w.2020.33
LSSTDataManagementBasePackage
|
Functions | |
def | makeConfigClass (ctrl, name=None, base=Config, doc=None, module=None, cls=None) |
def | wrap (ctrl) |
Variables | |
Control | |
makeControl | |
readControl | |
setDefaults | |
validate | |
def pex.config.wrap.makeConfigClass | ( | ctrl, | |
name = None , |
|||
base = Config , |
|||
doc = None , |
|||
module = None , |
|||
cls = None |
|||
) |
Create a `~lsst.pex.config.Config` class that matches a C++ control object class. See the `wrap` decorator as a convenient interface to ``makeConfigClass``. Parameters ---------- ctrl : class C++ control class to wrap. name : `str`, optional Name of the new config class; defaults to the ``__name__`` of the control class with ``'Control'`` replaced with ``'Config'``. base : `lsst.pex.config.Config`-type, optional Base class for the config class. doc : `str`, optional Docstring for the config class. module : object, `str`, `int`, or `None` optional Either a module object, a string specifying the name of the module, or an integer specifying how far back in the stack to look for the module to use: 0 is the immediate caller of `~lsst.pex.config.wrap`. This will be used to set ``__module__`` for the new config class, and the class will also be added to the module. Ignored if `None` or if ``cls`` is not `None`. Defaults to None in which case module is looked up from the module of ctrl. cls : class An existing config class to use instead of creating a new one; name, base doc, and module will be ignored if this is not `None`. Notes ----- To use ``makeConfigClass``, write a control object in C++ using the ``LSST_CONTROL_FIELD`` macro in ``lsst/pex/config.h`` (note that it must have sensible default constructor): .. code-block:: cpp // myHeader.h struct InnerControl { LSST_CONTROL_FIELD(wim, std::string, "documentation for field 'wim'"); }; struct FooControl { LSST_CONTROL_FIELD(bar, int, "documentation for field 'bar'"); LSST_CONTROL_FIELD(baz, double, "documentation for field 'baz'"); LSST_NESTED_CONTROL_FIELD(zot, myWrappedLib, InnerControl, "documentation for field 'zot'"); FooControl() : bar(0), baz(0.0) {} }; You can use ``LSST_NESTED_CONTROL_FIELD`` to nest control objects. Wrap those control objects as you would any other C++ class, but make sure you include ``lsst/pex/config.h`` before including the header file where the control object class is defined. Next, in Python: .. code-block:: py import lsst.pex.config import myWrappedLib InnerConfig = lsst.pex.config.makeConfigClass(myWrappedLib.InnerControl) FooConfig = lsst.pex.config.makeConfigClass(myWrappedLib.FooControl) This does the following things: - Adds ``bar``, ``baz``, and ``zot`` fields to ``FooConfig``. - Set ``FooConfig.Control`` to ``FooControl``. - Adds ``makeControl`` and ``readControl`` methods to create a ``FooControl`` and set the ``FooConfig`` from the ``FooControl``, respectively. - If ``FooControl`` has a ``validate()`` member function, a custom ``validate()`` method will be added to ``FooConfig`` that uses it. All of the above are done for ``InnerConfig`` as well. Any field that would be injected that would clash with an existing attribute of the class is be silently ignored. This allows you to customize fields and inherit them from wrapped control classes. However, these names are still be processed when converting between config and control classes, so they should generally be present as base class fields or other instance attributes or descriptors. While ``LSST_CONTROL_FIELD`` will work for any C++ type, automatic `~lsst.pex.config.Config` generation only supports ``bool``, ``int``, ``std::int64_t``, ``double``, and ``std::string`` fields, along with ``std::list`` and ``std::vectors`` of those types. See also -------- wrap
Definition at line 56 of file wrap.py.
def pex.config.wrap.wrap | ( | ctrl | ) |
Decorator that adds fields from a C++ control class to a `lsst.pex.config.Config` class. Parameters ---------- ctrl : object The C++ control class. Notes ----- See `makeConfigClass` for more information. This `wrap` decorator is equivalent to calling `makeConfigClass` with the decorated class as the ``cls`` argument. Examples -------- Use `wrap` like this:: @wrap(MyControlClass) class MyConfigClass(Config): pass See also -------- makeConfigClass
Definition at line 302 of file wrap.py.