#ifndef _utl_ConfigParameter_h_ #define _utl_ConfigParameter_h_ #include #include // std::string cannot be fwd-declared. /** * \file * \author Rodolfo Federico Gamarra * \date 19 Sep 2009 */ namespace utl { class RandomEngine; class VRandomSampler; class Branch; /** * \class ConfigParameter ConfigParameter.h Configuration/ConfigParameter.h * * \brief Helper class for configuration of parameters. * * Wraps random number generation, or other means of determining the value * of the wrapped parameter, it also handles the access to configuration. * * \author Rodolfo Federico Gamarra * \date 19 Sep 2009 * \ingroup */ class ConfigParameter { public: /** * \brief Alias for type of the paremeter. * * XXX May it be proper to have this class templatized on the parameter type? * In the end, we have a tight coupling with the underlying randomization * procedures which work with double. * If later that's desired, the arg should be defaulted to double and that's it. */ typedef double Type; /** * \brief Construction giving an engine and a branch from where to load configuration * data. */ ConfigParameter(utl::RandomEngine& eng, const utl::Branch& configData); /** * \brief Explicit declaratio+defintion so as to have, when defined, * also fully defined the pointed-to type of the nested std::auto_ptr. */ ~ConfigParameter(); /** * \brief Compute a configuration value. * * The value may be randomize, constant or taken from list: ie * value actual value returned may change betweeen invocations, tough * this function is const. */ Type operator()() const; /** * \brief Type of function to be used. */ enum FunctionType { eFixed, /**< Constant function. */ ePDF, /**< Probability density distribution. */ eCDF, /**< Cummulative density distribution. */ eValueList /**< The values are taken one-by-one from a list. */ }; /// Tags for the types of functions. static const char* const kFunctionTypeTags[]; /** * \brief Type of parametrization for the configured type of function. * * It's based on the constructors of the referenced types. * * Note that, for completeness, an enum is provided to match each * constructor, but the case for map is not implemented due to * the lack of a utl::Branch::GetData function with that parameter * type. * * \sa utl::RandomSamplerFromCDF * \sa utl::RandomSamplerFromPDF * \sa utl::Branch */ enum Parametrization { eFormula, eFormulaWithVariable, eMap, eTabulatedFunction, eVector, eVectorPair }; /// Tags for the types of parametrization static const char* const kParametrizationTags[]; /// Tags for the types of interpolation. static const char* const kInterpolationTags[]; private: utl::RandomEngine& fEngine; std::auto_ptr fSampler; mutable Type fLastValue; // placeholder for the last previous value. bool fDelta; }; } #endif // _utl_ConfigParameter_h_