SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
FileSystemItemDefinition.h
1 //=========================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //=========================================================================
10 // .NAME FileSystemItemDefinition.h -
11 // .SECTION Description
12 // .SECTION See Also
13 
14 #ifndef smtk_attribute_FileSystemItemDefinition_h
15 #define smtk_attribute_FileSystemItemDefinition_h
16 
17 #include "smtk/CoreExports.h"
18 #include "smtk/PublicPointerDefs.h"
19 
20 #include "smtk/attribute/ItemDefinition.h"
21 
22 namespace smtk
23 {
24 namespace attribute
25 {
26 class Attribute;
27 class SMTKCORE_EXPORT FileSystemItemDefinition : public ItemDefinition
28 {
29 public:
31 
32  ~FileSystemItemDefinition() override;
33 
34  Item::Type type() const override;
35  virtual bool isValueValid(const std::string& val) const;
36 
37  // Returns or Sets the def's extensiblity property. If true then items from this def
38  // can have a variable number of items. The number of items is always <= to number of
39  // required items and max number of items (provided max number of items > 0)
40  // Default value is false.
41  bool isExtensible() const { return m_isExtensible; }
42  void setIsExtensible(bool mode);
43 
44  std::size_t numberOfRequiredValues() const { return m_numberOfRequiredValues; }
45  bool setNumberOfRequiredValues(std::size_t esize);
46 
47  // Returns or Sets the maximum number of items that items from this def can have.
48  // if 0 is returned then there is no max limit. Default value is 0
49  // Note that this is used only when the def is extensible
50  std::size_t maxNumberOfValues() const { return m_maxNumberOfValues; }
51  // Returns false if the new max is less than the number of required groups
52  // and is not 0
53  bool setMaxNumberOfValues(std::size_t esize);
54 
55  bool hasValueLabels() const { return !m_valueLabels.empty(); }
56 
57  void setValueLabel(std::size_t element, const std::string& elabel);
58  void setCommonValueLabel(const std::string& elabel);
59  bool usingCommonLabel() const { return m_useCommonLabel; }
60  std::string valueLabel(std::size_t element) const;
61  bool shouldExist() const { return m_shouldExist; }
62  void setShouldExist(bool val) { m_shouldExist = val; }
63  bool shouldBeRelative() const { return m_shouldBeRelative; }
64  void setShouldBeRelative(bool val) { m_shouldBeRelative = val; }
65  std::string defaultValue() const { return m_defaultValue; }
66  void setDefaultValue(const std::string& val);
67  void unsetDefaultValue() { m_hasDefault = false; }
68  bool hasDefault() const { return m_hasDefault; }
69  smtk::attribute::ItemPtr buildItem(Attribute* owningAttribute, int itemPosition) const override =
70  0;
71  smtk::attribute::ItemPtr buildItem(Item* owningItem, int position, int subGroupPosition)
72  const override = 0;
73 
75  smtk::attribute::ItemDefinition::CopyInfo& info) const override = 0;
76 
77 protected:
78  FileSystemItemDefinition(const std::string& myName);
79  bool m_shouldExist;
80  bool m_shouldBeRelative;
81  bool m_useCommonLabel;
82  bool m_isExtensible;
83  bool m_hasDefault;
84  std::string m_defaultValue;
85  std::vector<std::string> m_valueLabels;
86  std::size_t m_numberOfRequiredValues;
87  std::size_t m_maxNumberOfValues;
88 
89 private:
90 };
91 } // namespace attribute
92 } // namespace smtk
93 
94 #endif /* smtk_attribute_FileSystemItemDefinition_h */
smtk
The main namespace for the Simulation Modeling Tool Kit (SMTK).
Definition: doc.h:33
smtk::attribute::Item::Type
Type
Definition: Item.h:52
PublicPointerDefs.h
smtk::attribute::ItemDefinition
Definition: ItemDefinition.h:37
smtk::attribute::ItemDefinition::CopyInfo
Definition: ItemDefinition.h:47
smtk::attribute::Item
Definition: Item.h:43
smtkTypeMacro
#define smtkTypeMacro(...)
Add typedefs to a class for identifcation.
Definition: SharedFromThis.h:51
smtk::attribute::Attribute
Represent a (possibly composite) value according to a definition.
Definition: Attribute.h:49
smtk::attribute::ItemPtr
smtk::shared_ptr< smtk::attribute::Item > ItemPtr
Definition: PublicPointerDefs.h:467
smtk::attribute::FileSystemItemDefinition
Definition: FileSystemItemDefinition.h:27
smtk::attribute::ItemDefinitionPtr
smtk::shared_ptr< smtk::attribute::ItemDefinition > ItemDefinitionPtr
Definition: PublicPointerDefs.h:473