|
|
|||
File indexing completed on 2026-06-02 08:51:42
0001 #ifndef BASE_OBJECT_DATA_H 0002 #define BASE_OBJECT_DATA_H 0003 0004 /** 0005 * @file BaseObjectData.h 0006 * @author Bryan BERTHOU (SPhN / CEA Saclay) 0007 * @date October 28, 2016 0008 * @version 1.0 0009 */ 0010 0011 #include <ElementaryUtils/parameters/Parameters.h> 0012 #include <map> 0013 #include <string> 0014 0015 #include "../../BaseObject.h" 0016 0017 namespace ElemUtils { 0018 class Parameter; 0019 } /* namespace ElemUtils */ 0020 0021 namespace PARTONS { 0022 0023 /** 0024 * @class BaseObjectData 0025 * 0026 * @brief Container to store data to be used by base objects. 0027 * 0028 * This class is a container to store data used by base objects in the automation process. 0029 * An object of this class is intended to be created by a XML parser during running PARTONS runtime from a specific XML file, which can be local or can be retrieved from a database. 0030 * Therefore, this class may be seen as a representation of a set of parameters encoded in a XML file, like: 0031 \code{.py} 0032 <kinematics type="GPDKinematic"> 0033 <param name="x" value="0.1" /> 0034 <param name="xi" value="0.05" /> 0035 <param name="t" value="-0.3" /> 0036 <param name="MuF2" value="8." /> 0037 <param name="MuR2" value="8." /> 0038 </kinematics> 0039 \endcode 0040 */ 0041 class BaseObjectData: public BaseObject { 0042 0043 public: 0044 0045 /** 0046 * Default constructor. 0047 */ 0048 BaseObjectData(); 0049 0050 /** 0051 * Assignment constructor. 0052 * @param moduleType Type of module intended to use parameters stored in this class. 0053 * @param moduleClassName Name of module intended to use parameters stored in this class. 0054 */ 0055 BaseObjectData(const std::string &moduleType, 0056 const std::string &moduleClassName); 0057 0058 /** 0059 * Destructor. 0060 */ 0061 virtual ~BaseObjectData(); 0062 0063 /** 0064 * Add submodule, i.e. indicate that this BaseObjectData object has a tree-like structure. 0065 * @param moduleType Type of module intended to use parameters stored in this class. 0066 * @param moduleClassName Name of module intended to use parameters stored in this class. 0067 * @return Reference to added BaseObjectData object. 0068 */ 0069 BaseObjectData& addSubModule(const std::string &moduleType, 0070 const std::string &moduleClassName); 0071 0072 /** 0073 * Add submodule, i.e. indicate that this BaseObjectData object has a tree-like structure. 0074 * @param baseObjectData BaseObjectData object. 0075 */ 0076 void addSubModule(const BaseObjectData& baseObjectData); 0077 0078 /** 0079 * Add a single parameter. 0080 * @param parameter Parameter to be added. 0081 */ 0082 void addParameter(const ElemUtils::Parameter ¶meter); 0083 0084 /** 0085 * Add a set of parameters. 0086 * @param parameters Parameters to be added. 0087 */ 0088 void addParameters(const ElemUtils::Parameters ¶meters); 0089 0090 /** 0091 * Check if parameters of submodule of a given type are available. 0092 * @param moduleClassType Requested type of submodule. 0093 * @return True if parameters are available, otherwise false. 0094 */ 0095 bool isAvailableSubModule(const std::string &moduleClassType) const; 0096 0097 /** 0098 * Get BaseObjectData object indicated by the last call of BaseObjectData::isAvailableSubModule() function. 0099 * @return Reference to object marked by the last call of BaseObjectData::isAvailableSubModule() function. 0100 */ 0101 const BaseObjectData& getLastAvailable() const; // Care ! Use it after isAvailable() to ensure that the iterator is in the map range. 0102 0103 virtual std::string toString() const; 0104 0105 //******************************************************** 0106 //*** SETTERS AND GETTERS ******************************** 0107 //******************************************************** 0108 0109 /** 0110 * Get type of module intended to use parameters stored in this class. 0111 */ 0112 const std::string& getModuleType() const; 0113 0114 /** 0115 * Set type of module intended to use parameters stored in this class. 0116 */ 0117 void setModuleType(const std::string& moduleType); 0118 0119 /** 0120 * Get name of module intended to use parameters stored in this class. 0121 */ 0122 const std::string& getModuleClassName() const; 0123 0124 /** 0125 * Set name of module intended to use parameters stored in this class. 0126 */ 0127 void setModuleClassName(const std::string& moduleClassName); 0128 0129 /** 0130 * Get parameters stored in this class. 0131 */ 0132 const ElemUtils::Parameters& getParameters() const; 0133 0134 /** 0135 * Set parameters stored in this class. 0136 */ 0137 void setParameters(const ElemUtils::Parameters& parameters); 0138 0139 /** 0140 * Get map to build a tree-like structure of BaseObjectData objects to be used if submodules are used. The keys in the map indicate type of modules intended to use parameters stored in corresponding BaseObjectData objects. 0141 */ 0142 const std::map<std::string, BaseObjectData>& getSubModules() const; 0143 0144 private: 0145 0146 /** 0147 * Type of module intended to use parameters stored in this class. 0148 */ 0149 std::string m_moduleType; 0150 0151 /** 0152 * Name of module intended to use parameters stored in this class. 0153 */ 0154 std::string m_moduleClassName; 0155 0156 /** 0157 * Parameters stored in this class. 0158 */ 0159 ElemUtils::Parameters m_parameters; 0160 0161 /** 0162 * Map to build a tree-like structure of BaseObjectData objects to be used if submodules are used. The keys in the map indicate type of modules intended to use parameters stored in corresponding BaseObjectData objects. 0163 */ 0164 std::map<std::string, BaseObjectData> m_subModules; 0165 0166 //Mutable keyword is use too indicate that member can be modify in const function. In this case useful with iterator m_it & isAvailable() function. 0167 /** 0168 * Iterator of BaseObjectData::m_subModules map. 0169 */ 0170 mutable std::map<std::string, BaseObjectData>::const_iterator m_it; 0171 }; 0172 0173 } /* namespace PARTONS */ 0174 0175 #endif /* BASE_OBJECT_DATA_H */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|