OpenLexocad  28.0
PropertyEnumDescriptor.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 namespace Core
6 {
7 /* @brief Saves and restores the characteristics of a PropertyEnum
8  */
9 class LX_CORE_EXPORT PropertyEnumDescriptor : public Core::PropertyDescriptor
10 {
13 public:
14  friend class PropertyEnumDescriptor_Factory;
16 
18  {
22 
23  bool operator==(const CustomTranslation& other) const { return en == other.en && fr == other.fr && it == other.it; }
24  bool allEmpty() const { return en.empty() && fr.empty() && it.empty(); }
25  };
26 
27  PropertyBoolean fix; // fix has only one entry
29 
30  // "geom. limit" that determines the value
35 
36  virtual size_t addEntry(const Base::String& aValue, int aTranslationId, const Base::String& code = Base::String());
37  virtual size_t addEntry(const Base::String& aValue, const CustomTranslation& ct, const Base::String& code = Base::String());
38  bool getEntry(size_t aIndex, std::pair<Base::String, int>& aEntry) const;
39  bool getEntry(size_t aIndex, std::pair<Base::String, int>& aEntry, CustomTranslation& ct) const;
40  bool getEntry(size_t aIndex, std::tuple<Base::String, int, CustomTranslation, Base::String>& aEntry) const;
41  bool getTranslatedEntry(size_t aIndex, Base::String& aValueTr) const;
42  virtual bool removeEntry(size_t aIndex);
43  std::vector<std::pair<Base::String, int>> getEntries() const;
44  std::vector<std::tuple<Base::String, int, CustomTranslation>> getEntriesWithCT() const;
45  std::vector<std::tuple<Base::String, int, CustomTranslation, Base::String>> getEntriesWithCTAndCode() const;
46  std::vector<Base::String> getTranslatedEntries() const;
47  virtual void setEmpty();
49  bool getIndex(const Base::String& aValue, size_t& aIndex) const;
50  Base::String getCode(size_t aIndex) const;
52  bool isNPKOpenPosition(size_t aIndex) const;
53 
55 
56  Type getType() const override;
57  size_t getSize() const;
58 
59  size_t computeHash(bool strictComparison) override;
60  long getEnumsTransactionNumber() const { return enums.getTransactionNumber(); }
61 
62 protected:
63  Core::DocObject* copy(Core::CoreDocument* toDoc, DocObjectMap& copyMap) override;
65  const Base::String& name,
68 
69 private:
70  PropertyTextList enums;
71  PropertyIndexList translationIds;
72  PropertyTextListOpt enumsEn;
73  PropertyTextListOpt enumsFr;
74  PropertyTextListOpt enumsIt;
75  PropertyTextListOpt codes; // "code" (text) for each enum value
76 };
77 
79 DECLARE_OBJECT_FACTORY_NOIFC(PropertyEnumDescriptor_Factory, PropertyEnumDescriptor);
80 } // namespace Core
Core::PropertyEnumDescriptor::restoreProperty
void restoreProperty(Core::Property *property, const Base::String &name, Base::AbstractXMLReader &reader, Base::PersistenceVersion &version) override
Restores property from from reader in specified version.
Core::PropertyEnumDescriptor
Definition: PropertyEnumDescriptor.h:10
Core::PropertyEnumDescriptor::getEntry
bool getEntry(size_t aIndex, std::tuple< Base::String, int, CustomTranslation, Base::String > &aEntry) const
Core::CoreDocument
Definition: CoreDocument.h:269
Core::PropertyEnumDescriptor::computeHash
size_t computeHash(bool strictComparison) override
Core::PropertyEnumDescriptor::getSize
size_t getSize() const
Core::PropertyEnumDescriptor::getEnumsTransactionNumber
long getEnumsTransactionNumber() const
Definition: PropertyEnumDescriptor.h:60
Core::DocObjectMap
std::map< Core::DocObject *, Core::DocObject * > DocObjectMap
Definition: DocObject.h:50
Core::PropertyBoolean
Definition: PropertyBoolean.h:14
Core::PropertyDescriptor::Type
Type
Definition: PropertyDescriptor.h:18
Core::PropertyEnumDescriptor::addEntry
virtual size_t addEntry(const Base::String &aValue, int aTranslationId, const Base::String &code=Base::String())
Core::PropertyEnumDescriptor::copy
Core::DocObject * copy(Core::CoreDocument *toDoc, DocObjectMap &copyMap) override
Core::PropertyEnumDescriptor::fix
PropertyBoolean fix
Definition: PropertyEnumDescriptor.h:27
Core::PropertyEnumDescriptor::getEntry
bool getEntry(size_t aIndex, std::pair< Base::String, int > &aEntry, CustomTranslation &ct) const
PropertyDescriptor.h
Core::PropertyEnumDescriptor::addEntry
virtual size_t addEntry(const Base::String &aValue, const CustomTranslation &ct, const Base::String &code=Base::String())
Core::PropertyEnumDescriptor::CustomTranslation::fr
Base::String fr
Definition: PropertyEnumDescriptor.h:20
Core::PropertyEnumDescriptor::getCode
Base::String getCode(size_t aIndex) const
Core::PropertyEnumDescriptor::getType
Type getType() const override
Core::DocObject
Definition: DocObject.h:54
Core::PropertyEnumDescriptor::automaticValueLimits
PropertyRealList automaticValueLimits
Definition: PropertyEnumDescriptor.h:34
Core::PropertyEnumDescriptor::removeEntry
virtual bool removeEntry(size_t aIndex)
Core::PropertyEnumDescriptor::CustomTranslation::allEmpty
bool allEmpty() const
Definition: PropertyEnumDescriptor.h:24
Base::PersistenceVersion
Definition: Persistence.h:13
Core::PropertyEnumDescriptor::getEntriesWithCT
std::vector< std::tuple< Base::String, int, CustomTranslation > > getEntriesWithCT() const
Core::PropertyIndexList
Definition: PropertyInteger.h:140
Core::PropertyEnumDescriptor::CustomTranslation::operator==
bool operator==(const CustomTranslation &other) const
Definition: PropertyEnumDescriptor.h:23
Core::PropertyEnumDescriptor::setEmpty
virtual void setEmpty()
Core
Definition: Base.h:5
Core::PropertyEnumDescriptor::CustomTranslation::en
Base::String en
Definition: PropertyEnumDescriptor.h:19
Core::PropertyEnumDescriptor::automaticValueUnit
PropertyText automaticValueUnit
Definition: PropertyEnumDescriptor.h:31
LX_NODE_HEADER
#define LX_NODE_HEADER()
Definition: PropertyMacros.h:7
Core::PropertyDescriptor
Definition: PropertyDescriptor.h:11
Core::DECLARE_OBJECT_FACTORY_NOIFC
DECLARE_OBJECT_FACTORY_NOIFC(PropertyBoolDescriptor_Factory, PropertyBoolDescriptor)
Core::PropertyEnumDescriptor::getTranslatedEntries
std::vector< Base::String > getTranslatedEntries() const
Base::AbstractXMLReader
Definition: AbstractXMLReader.h:7
Core::PropertyEnumDescriptor::getIndex
bool getIndex(const Base::String &aValue, size_t &aIndex) const
Returns true/index of the value in enums, false if it is not found.
Core::PropertyText
Definition: PropertyText.h:8
Core::PropertyEnumDescriptor::CustomTranslation::it
Base::String it
Definition: PropertyEnumDescriptor.h:21
Core::PropertyEnumDescriptor::PropertyEnumDescriptor
PropertyEnumDescriptor()
Core::PropertyEnumDescriptor::CustomTranslation
Definition: PropertyEnumDescriptor.h:18
Core::PropertyTextList
Definition: PropertyTextList.h:8
Core::PropertyEnumDescriptor::getEntry
bool getEntry(size_t aIndex, std::pair< Base::String, int > &aEntry) const
Core::PropertyEnumDescriptor::automaticValueFactor
PropertyReal automaticValueFactor
Definition: PropertyEnumDescriptor.h:33
Core::version
LX_CORE_EXPORT Version & version
Core::PropertyRealList
Definition: PropertyReal.h:43
Core::Property
Definition: Property.h:72
Core::PropertyEnumDescriptor::automaticValueDetail
PropertyText automaticValueDetail
Definition: PropertyEnumDescriptor.h:32
Core::DECLARE_PROPERTY_TEMPLATES
DECLARE_PROPERTY_TEMPLATES(Core::ColorSetForPED, LX_CORE_EXPORT)
Base::String
A Utf-16 (windows) or ucs4 (unix) encoded string class.
Definition: String.h:18
Core::PropertyEnumDescriptor::getEntriesWithCTAndCode
std::vector< std::tuple< Base::String, int, CustomTranslation, Base::String > > getEntriesWithCTAndCode() const
Core::PropertyEnumDescriptor::defaultValueIndex
PropertyInteger defaultValueIndex
Definition: PropertyEnumDescriptor.h:28
Core::PropertyEnumDescriptor::getTranslatedEntry
bool getTranslatedEntry(size_t aIndex, Base::String &aValueTr) const
Core::PropertyReal
Definition: PropertyReal.h:8
TYPESYSTEM_HEADER
#define TYPESYSTEM_HEADER()
define for subclassing Base::BaseClass
Definition: Base.h:12
Core::PropertyEnumDescriptor::isNPKOpenPosition
bool isNPKOpenPosition(size_t aIndex) const
Returns true for the properties from Lcc data with 'o' code.
Core::PropertyEnumDescriptor::getEntries
std::vector< std::pair< Base::String, int > > getEntries() const
Core::PropertyInteger
Definition: PropertyInteger.h:8
Base::String::empty
bool empty() const