ICF 3.1.1.10
Technical documentation of ICF Libraries
COptionsManager.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#ifndef iprm_COptionsManager_included
7#define iprm_COptionsManager_included
8
9
10// Qt includes
11#include <QtCore/QVector>
12
13// ICF includes
16
17
18namespace iprm
19{
20
21
22class IOptionsList;
23
24
29 public CSelectionParam,
30 virtual public IOptionsManager
31{
32public:
34
36
40 void SetFixedOptionsList(const iprm::IOptionsList* slaveSelectionConstraintsPtr);
41
45 virtual void ResetOptions();
46
51 int GetOptionIndexById(const QByteArray& optionId) const;
52
58 int GetOptionIndexByName(const QString& optionName) const;
59
64
68 void SetSelectionSerialized(bool state);
69
70 // reimplemented (iprm::IOptionsList)
71 int GetOptionsFlags() const override;
72 int GetOptionsCount() const override;
73 QString GetOptionName(int index) const override;
74 QString GetOptionDescription(int index) const override;
75 QByteArray GetOptionId(int index) const override;
76 bool IsOptionEnabled(int index) const override;
77
78 // reimplemented (iprm::IOptionsManager)
79 int GetOptionOperationFlags(int index = -1) const override;
80 bool SetOptionEnabled(int index, bool isEnabled = true) override;
81 bool RemoveOption(int index) override;
83 const QString& optionName,
84 const QByteArray& optionId,
85 const QString& optionDescription = QString(),
86 int index = -1) override;
87 bool SwapOptions(int index1, int index2) override;
88 bool SetOptionName(int index, const QString& optionName) override;
89 bool SetOptionDescription(int index, const QString& optionDescription) override;
90
91 // reimplemented (iser::ISerializable)
92 bool Serialize(iser::IArchive& archive) override;
93
94 // reimplemented (iser::IChangeable)
95 int GetSupportedOperations() const override;
96 bool CopyFrom(const IChangeable& object, CompatibilityMode mode = CM_WITHOUT_REFS) override;
97
98private:
99 struct OptionInfo
100 {
101 OptionInfo()
102 : isEnabled(true)
103 {
104 }
105
106 OptionInfo(const QString& optionName, QByteArray optionId, const QString& optionDescription)
107 : optionName(optionName),
108 optionId(optionId),
109 optionDescription(optionDescription),
110 isEnabled(true)
111 {
112 }
113
114 QString optionName;
115 QByteArray optionId;
116 QString optionDescription;
117 bool isEnabled;
118 };
119
120 typedef QVector<OptionInfo> Options;
121
122 Options m_options;
123
124 const iprm::IOptionsList* m_slaveSelectionConstraintsPtr;
125
126 bool m_isSelectionSerialized;
127};
128
129
130} // namespace iprm
131
132
133#endif // !iprm_COptionsManager_included
134
135
Implementation of a simple options manager.
bool SetOptionEnabled(int index, bool isEnabled=true) override
Enables a given option.
int GetOptionIndexByName(const QString &optionName) const
Get the index for the given option name.
bool InsertOption(const QString &optionName, const QByteArray &optionId, const QString &optionDescription=QString(), int index=-1) override
Insert an option at some position.
QByteArray GetOptionId(int index) const override
Get option ID.
void SetFixedOptionsList(const iprm::IOptionsList *slaveSelectionConstraintsPtr)
Set additional fixed list of options.
bool SwapOptions(int index1, int index2) override
Swap two options.
int GetOptionIndexById(const QByteArray &optionId) const
Get the index for the given option ID.
bool Serialize(iser::IArchive &archive) override
Load or store state of this object as a archive stream.
int GetOptionsCount() const override
Get number of managed options.
int GetSupportedOperations() const override
Get set of flags for supported operations.
bool SetOptionDescription(int index, const QString &optionDescription) override
Set a new description for the option at the given index optionIndex.
bool RemoveOption(int index) override
Remove an option at the given index.
bool SetOptionName(int index, const QString &optionName) override
Set a new name for the option at the given index optionIndex.
bool IsOptionEnabled(int index) const override
Return true if the option is enabled and can be selected.
QString GetOptionName(int index) const override
Get name of specified option.
virtual void ResetOptions()
Removes all options.
void SetSelectionSerialized(bool state)
Turn on or off selection serializing.
int GetOptionOperationFlags(int index=-1) const override
Get operation control flags of some option or whole manager.
int GetOptionsFlags() const override
Get constraints flags.
CSelectionParam BaseClass
bool IsSelectionSerialized() const
Check if selection is serialized.
bool CopyFrom(const IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS) override
QString GetOptionDescription(int index) const override
Get human readable description for a option with the index index.
Basic implementation of selection parameter.
Constraints of selection from set of possibilities.
Common interface for the management of the dynamic selection constraints.
Represent input/output persistence archive.
Definition IArchive.h:34
CompatibilityMode
Control how relationship betweeen objects are interpreted.
@ CM_WITHOUT_REFS
External references are simple ignored.
Contains interfaces and implementations of flexible parameter concept.

© Witold Gantzke and Kirill Lepskiy