CParamsManagerCompBase.h
Go to the documentation of this file.
1 #ifndef iprm_CParamsManagerCompBase_included
2 #define iprm_CParamsManagerCompBase_included
3 
4 
5 // Qt includes
6 #include <QtCore/QVector>
7 
8 // ACF includes
9 #include <istd/TDelPtr.h>
10 #include <imod/TModelWrap.h>
12 #include <icomp/CComponentBase.h>
13 #include <iprm/IParamsSet.h>
14 #include <iprm/ISelectionParam.h>
15 #include <iprm/IOptionsManager.h>
16 #include <iprm/IParamsManager.h>
17 #include <iprm/CNameParam.h>
18 
19 
20 namespace iprm
21 {
22 
23 
25 {
26 public:
28 
29  I_BEGIN_BASE_COMPONENT(CParamsManagerCompBaseAttr);
30  I_ASSIGN(m_elementIndexParamIdAttrPtr, "ElementIndexParamId", "ID of index of returned parameter set in manager list", false, "Index");
31  I_ASSIGN(m_elementNameParamIdAttrPtr, "ElementNameParamId", "ID of the name of returned parameter set in manager list", false, "Name");
32  I_ASSIGN(m_elementDescriptionParamIdAttrPtr, "ElementDescriptionParamId", "ID of the description of returned parameter set in manager list", false, "Description");
33  I_ASSIGN_MULTI_0(m_fixedParamSetsCompPtr, "FixedParamSets", "List of references to fixed parameter set", false);
34  I_ASSIGN_MULTI_0(m_fixedSetNamesAttrPtr, "FixedSetNames", "List of fixed parameter names", false);
35  I_ASSIGN_MULTI_0(m_fixedSetDescriptionsAttrPtr, "FixedSetDescriptions", "List of fixed parameter descriptions", false);
36  I_ASSIGN_MULTI_0(m_fixedSetIdsAttrPtr, "FixedSetIds", "List of fixed parameter IDs", false);
37  I_ASSIGN(m_defaultSetNameAttrPtr, "DefaultSetName", "Default name of parameter set. Use %1 to insert automatic enumeration", true, "<noname>");
38  I_ASSIGN(m_serializeSelectionAttrPtr, "SerializeSelection", "If enabled, the current parameter set selection will be serialized", true, true);
39  I_ASSIGN(m_defaultSelectedIndexAttrPtr, "DefaultSelection", "If enabled, the given parameter set will be automatically selected", false, -1);
40  I_ASSIGN(m_allowDisabledAttrPtr, "AllowDisabled", "Control if disabled parameters are supported", true, false);
41  I_ASSIGN(m_supportEnablingAttrPtr, "SupportEnabling", "Control if enabling or disabling of parameters is allowed (works only if disabled parameters are supported)", true, true);
42  I_ASSIGN(m_allowEditFixedAttrPtr, "AllowEditFixed", "If enabled, the editing of fixed parameters is enabled", true, true);
43  I_END_COMPONENT;
44 
45 protected:
46  I_MULTIREF(IParamsSet, m_fixedParamSetsCompPtr);
47  I_MULTITEXTATTR(m_fixedSetNamesAttrPtr);
48  I_MULTITEXTATTR(m_fixedSetDescriptionsAttrPtr);
49  I_MULTIATTR(QByteArray, m_fixedSetIdsAttrPtr);
50  I_TEXTATTR(m_defaultSetNameAttrPtr);
51  I_ATTR(bool, m_serializeSelectionAttrPtr);
52  I_ATTR(int, m_defaultSelectedIndexAttrPtr);
53  I_ATTR(bool, m_allowDisabledAttrPtr);
54  I_ATTR(bool, m_supportEnablingAttrPtr);
55  I_ATTR(bool, m_allowEditFixedAttrPtr);
56  I_ATTR(QByteArray, m_elementIndexParamIdAttrPtr);
57  I_ATTR(QByteArray, m_elementNameParamIdAttrPtr);
58  I_ATTR(QByteArray, m_elementDescriptionParamIdAttrPtr);
59 };
60 
61 
67  virtual public IParamsManager,
68  virtual public IOptionsManager
69 {
70 public:
72 
73  I_BEGIN_BASE_COMPONENT(CParamsManagerCompBase);
74  I_REGISTER_INTERFACE(ISelectionParam);
75  I_REGISTER_INTERFACE(IParamsManager);
76  I_REGISTER_INTERFACE(iser::ISerializable);
77  I_REGISTER_INTERFACE(IOptionsManager);
78  I_REGISTER_INTERFACE(IOptionsList);
79  I_REGISTER_SUBELEMENT(SelectedParams);
80  I_REGISTER_SUBELEMENT_INTERFACE(SelectedParams, iprm::IParamsSet, ExtractCurrentParams);
81  I_REGISTER_SUBELEMENT_INTERFACE(SelectedParams, iser::IObject, ExtractCurrentParams);
82  I_REGISTER_SUBELEMENT_INTERFACE(SelectedParams, iser::ISerializable, ExtractCurrentParams);
83  I_REGISTER_SUBELEMENT_INTERFACE(SelectedParams, istd::IChangeable, ExtractCurrentParams);
84  I_REGISTER_SUBELEMENT_INTERFACE(SelectedParams, imod::IModel, ExtractCurrentParams);
85  I_END_COMPONENT;
86 
88 
89  // reimplemented (iprm::IParamsManager)
90  virtual int InsertParamsSet(int typeIndex = -1, int index = -1);
91  virtual bool RemoveParamsSet(int index);
92  virtual bool SwapParamsSet(int index1, int index2);
93  virtual IParamsSet* GetParamsSet(int index) const;
94  virtual IParamsSet* CreateParameterSet(int typeIndex = -1, int index = -1) const;
95  virtual int GetIndexOperationFlags(int index = -1) const;
96  virtual int GetParamsSetsCount() const;
97  virtual QString GetParamsSetName(int index) const;
98  virtual bool SetParamsSetName(int index, const QString& name);
99  virtual QString GetParamsSetDescription(int index) const;
100  virtual void SetParamsSetDescription(int index, const QString& description);
101 
102  // reimplemented (iprm::ISelectionParam)
103  virtual const IOptionsList* GetSelectionConstraints() const;
104  virtual int GetSelectedOptionIndex() const;
105  virtual bool SetSelectedOptionIndex(int index);
106  virtual ISelectionParam* GetSubselection(int index) const;
107 
108  // reimplemented (iprm::IOptionsList)
109  virtual int GetOptionsFlags() const;
110  virtual int GetOptionsCount() const;
111  virtual QString GetOptionName(int index) const;
112  virtual QString GetOptionDescription(int index) const;
113  virtual QByteArray GetOptionId(int index) const;
114  virtual bool IsOptionEnabled(int index) const;
115 
116 protected:
117  void EnsureParamsSetModelDetached(iprm::IParamsSet* paramsSetPtr) const;
118  QString CalculateNewDefaultName() const;
119  int FindParamSetIndex(const QString& name) const;
120  int FindFixedParamSetIndex(const QString& name) const;
121 
122  // abstract methods
123 
127  virtual bool IsParameterCreationSupported() const = 0;
128 
132  virtual int GetCreatedParamsSetsCount() const = 0;
133 
137  virtual iprm::IParamsSet* CreateParamsSetInstance(int typeIndex = -1) const = 0;
138 
139  // reimplemented (icomp::CComponentBase)
140  virtual void OnComponentCreated();
141 
142 protected:
144 
145  class ParamSet:
146  virtual public IParamsSet,
147  virtual public ISelectionParam,
148  virtual public INameParam
149  {
150  public:
151  ParamSet();
152 
153  // reimplemented (iprm::IParamsSet)
154  virtual Ids GetParamIds(bool editableOnly = false) const;
155  virtual const iser::ISerializable* GetParameter(const QByteArray& id) const;
156  virtual iser::ISerializable* GetEditableParameter(const QByteArray& id);
157 
158  // reimplemented (iprm::ISelectionParam)
159  virtual const IOptionsList* GetSelectionConstraints() const;
160  virtual int GetSelectedOptionIndex() const;
161  virtual bool SetSelectedOptionIndex(int index);
162  virtual ISelectionParam* GetSubselection(int index) const;
163 
164  // reimplemented (iser::INameParam)
165  virtual const QString& GetName() const;
166  virtual void SetName(const QString& name);
167  virtual bool IsNameFixed() const;
168 
169  // reimplemented (iser::IObject)
170  virtual QByteArray GetFactoryId() const;
171 
172  // reimplemented (iser::ISerializable)
173  virtual bool Serialize(iser::IArchive& archive);
174 
176  QByteArray uuid;
177  QString name;
179  bool isEnabled;
181 
183  };
184 
185  class SelectedParams: virtual public IParamsSet
186  {
187  public:
188  SelectedParams();
189 
190  // reimplemented (iprm::IParamsSet)
191  virtual Ids GetParamIds(bool editableOnly = false) const;
192  virtual const iser::ISerializable* GetParameter(const QByteArray& id) const;
193  virtual iser::ISerializable* GetEditableParameter(const QByteArray& id);
194 
195  // reimplemented (iser::IObject)
196  virtual QByteArray GetFactoryId() const;
197 
198  // reimplemented (iser::ISerializable)
199  virtual bool Serialize(iser::IArchive& archive);
200 
202  };
203 
205 
206  typedef QList<ParamSetPtr> ParamSets;
207 
209 
211 
212 private:
213  // static template methods for subelement access
214  template <class InterfaceType>
215  static InterfaceType* ExtractCurrentParams(CParamsManagerCompBase& component)
216  {
217  return &component.m_selectedParams;
218  }
219 
220  imod::TModelWrap<SelectedParams> m_selectedParams;
221 };
222 
223 
224 } // namespace iprm
225 
226 
227 #endif // !iprm_CParamsManagerCompBase_included
228 
229 
virtual QByteArray GetOptionId(int index) const
Get option ID.
virtual bool RemoveParamsSet(int index)
Remove parameters set at selected position.
virtual Ids GetParamIds(bool editableOnly=false) const
Get list of used parameter IDs in the parameter set.
I_TEXTATTR(m_defaultSetNameAttrPtr)
int FindFixedParamSetIndex(const QString &name) const
QSet< QByteArray > Ids
Definition: IParamsSet.h:26
virtual bool IsParameterCreationSupported() const =0
Return true if creation of parameter sets is supported by the implementation.
Manager of parameters set.
virtual bool SetSelectedOptionIndex(int index)
Set index of selected option.
virtual bool SetParamsSetName(int index, const QString &name)
Set name of specified parameter set.
virtual bool SwapParamsSet(int index1, int index2)
Swap two parameter sets.
Interface for a object containing simple text.
Definition: INameParam.h:20
virtual bool Serialize(iser::IArchive &archive)
Load or store state of this object as a archive stream.
virtual const iser::ISerializable * GetParameter(const QByteArray &id) const
Get any parameter.
Base class for component implementation.
virtual const iser::ISerializable * GetParameter(const QByteArray &id) const
Get any parameter.
virtual iprm::IParamsSet * CreateParamsSetInstance(int typeIndex=-1) const =0
Create a new instance of the parameter set.
virtual const IOptionsList * GetSelectionConstraints() const
Get constraints of this parameter.
Implementation of a named object over iprm::INameParam interface.
Definition: CNameParam.h:16
imod::CModelUpdateBridge m_updateBridge
virtual QString GetOptionName(int index) const
Get name of specified option.
Constraints of selection from set of possibilities.
Definition: IOptionsList.h:22
I_MULTITEXTATTR(m_fixedSetNamesAttrPtr)
Common class for all classes which objects can be archived or restored from archive.
Definition: ISerializable.h:23
Common interface for factorisable model objects.
Definition: IObject.h:19
virtual const QString & GetName() const
Get the object name.
Common interface for the management of the dynamic selection constraints.
virtual bool IsOptionEnabled(int index) const
Return true if the option is enabled and can be selected.
virtual int GetSelectedOptionIndex() const
Get selected index.
virtual IParamsSet * GetParamsSet(int index) const
Get selected parameter set.
virtual int GetIndexOperationFlags(int index=-1) const
Get operation control flags of some paramter set or whole manager.
virtual QString GetParamsSetName(int index) const
Get name of specified parameter set.
Represent input/output persistence archive.
Definition: IArchive.h:30
Common interface for data model objects, which can be changed.
Definition: IChangeable.h:24
virtual QByteArray GetFactoryId() const
virtual bool Serialize(iser::IArchive &archive)
Load or store state of this object as a archive stream.
virtual void SetName(const QString &name)
Set the object name.
virtual int GetCreatedParamsSetsCount() const =0
Get the number of parameter sets created at the run time.
virtual int GetSelectedOptionIndex() const
Get selected index.
virtual Ids GetParamIds(bool editableOnly=false) const
Get list of used parameter IDs in the parameter set.
int FindParamSetIndex(const QString &name) const
virtual iser::ISerializable * GetEditableParameter(const QByteArray &id)
Get access to editable parameter.
virtual bool IsNameFixed() const
Return true, if the name setting is enabled.
virtual const IOptionsList * GetSelectionConstraints() const
Get constraints of this parameter.
virtual QString GetParamsSetDescription(int index) const
Get the description of the specified parameter set.
virtual ISelectionParam * GetSubselection(int index) const
Get subselection for specified option.
virtual QByteArray GetFactoryId() const
Reflects the changes of observed objects as changes of some other object (over istd::IChangeable), typically delegated to itself.
virtual int GetParamsSetsCount() const
Get number of managed set.
This model wrapper provides a simple connection between a concrete istd::IChangeable implementation a...
Definition: TModelWrap.h:24
virtual iser::ISerializable * GetEditableParameter(const QByteArray &id)
Get access to editable parameter.
istd::TDelPtr< ParamSet > ParamSetPtr
virtual IParamsSet * CreateParameterSet(int typeIndex=-1, int index=-1) const
virtual int GetOptionsCount() const
Get number of managed options.
virtual QString GetOptionDescription(int index) const
Get human readable description for a option with the index index.
Common interface for model objects, that supports Model/Observer design pattern.
Definition: IModel.h:23
Interface allowing to select single option from list of options.
CParamsManagerCompBaseAttr BaseClass
Implementation of parameter manager.
Set of general parameters.
Definition: IParamsSet.h:23
virtual void SetParamsSetDescription(int index, const QString &description)
Set the description of the specified parameter set.
QString CalculateNewDefaultName() const
virtual int GetOptionsFlags() const
Get constraints flags.
virtual int InsertParamsSet(int typeIndex=-1, int index=-1)
Insert new parameters set at selected position.
virtual ISelectionParam * GetSubselection(int index) const
Get subselection for specified option.
void EnsureParamsSetModelDetached(iprm::IParamsSet *paramsSetPtr) const
Pointer wrapper providing automatic deleting pointed object during destruction.
Definition: TDelPtr.h:20
virtual void OnComponentCreated()
virtual bool SetSelectedOptionIndex(int index)
Set index of selected option.

© 2007-2017 Witold Gantzke and Kirill Lepskiy