class mrpt::config::OptionsCapable
Overview
Mixin interface for classes that expose one or more CLoadableOptions structures (e.g.
“insertionOptions”, “likelihoodOptions”, “renderOptions”) in a generic, name-indexed way, so that callers never need to know the concrete class nor the exact set/names of options structures it defines works uniformly for all present and future classes implementing this interface.
“Creation options” (those that configure a class’ internal structure, e.g. a voxel/grid size) are handled separately via trySetCreationOptions(), since changing them may be incompatible with already-built internal state.
#include <mrpt/config/OptionsCapable.h> class OptionsCapable { public: // construction OptionsCapable(); OptionsCapable(const OptionsCapable&); OptionsCapable(OptionsCapable&&); // methods OptionsCapable& operator = (const OptionsCapable&); OptionsCapable& operator = (OptionsCapable&&); virtual std::map<std::string, mrpt::config::CLoadableOptions*> optionsByName() = 0; virtual bool trySetCreationOptions(] const mrpt::config::CConfigFileBase& cfg, ] const std::string& section); }; // direct descendants template <class octree_t, class octree_node_t> class COctoMapBase; template <typename voxel_node_t, typename occupancy_t = int8_t> class CVoxelMapOccupancyBase; class CBeaconMap; class CGasConcentrationGridMap2D; class CHeightGridMap2D; class CHeightGridMap2D_MRF; class COccupancyGridMap2D; class COccupancyGridMap3D; class CPointsMap; class CRandomFieldGridMap3D; class CReflectivityGridMap2D; class CWirelessPowerGridMap2D;
Methods
virtual std::map<std::string, mrpt::config::CLoadableOptions*> optionsByName() = 0
Maps an options-group name (e.g.
“insertionOptions”) to a pointer to the corresponding, live CLoadableOptions member. Pointers remain valid as long as this is alive, and point directly to the actual option members (no copies), so writes through them (e.g. via loadFromConfigFile()) take effect immediately.
Implementations should list every CLoadableOptions member they define, INCLUDING “creationOptions” if present (so it can be discovered/exported generically); however, callers must use trySetCreationOptions(), not a direct write through this pointer, to safely modify creation options.
virtual bool trySetCreationOptions(] const mrpt::config::CConfigFileBase& cfg, ] const std::string& section)
Attempts to apply new “creation options” (i.e.
those that configure an internal structure, such as a voxel/grid size), read from the given section of cfg.
Many creation-time parameters are just runtime thresholds with no effect on already-built internal structures, so applying them in place is often possible even after the object holds data. Others (e.g. a voxel size) cannot be changed without discarding existing contents.
Returns:
true if the new options were applied; false if doing so would require destroying the object’s current contents (in which case it is left unmodified) or if this class does not define any “creationOptions” group at all (the default implementation).