SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
11 #ifndef smtk_attribute_ReferenceItemDefinition_h
12 #define smtk_attribute_ReferenceItemDefinition_h
14 #include "smtk/attribute/ItemDefinition.h"
16 #include "smtk/common/UUID.h"
18 #include "smtk/resource/Resource.h"
24 #include <unordered_set>
58 Item::Type type()
const override {
return Item::ReferenceType; }
60 const std::multimap<std::string, std::string>& acceptableEntries()
const {
return m_acceptable; }
63 setAcceptsEntries(
const std::string&
typeName,
const std::string& queryString,
bool accept);
65 void clearAcceptableEntries() { m_acceptable.clear(); }
67 const std::multimap<std::string, std::string>& rejectedEntries()
const {
return m_rejected; }
70 setRejectsEntries(
const std::string&
typeName,
const std::string& queryString,
bool accept);
72 void clearRejectedEntries() { m_rejected.clear(); }
74 void setEnforcesCategories(
bool mode) { m_enforcesCategories = mode; }
75 bool enforcesCategories()
const {
return m_enforcesCategories; }
80 std::size_t numberOfRequiredValues()
const;
82 void setNumberOfRequiredValues(std::size_t esize);
84 bool isExtensible()
const {
return m_isExtensible; }
85 void setIsExtensible(
bool extensible) { m_isExtensible = extensible; }
87 std::size_t maxNumberOfValues()
const {
return m_maxNumberOfValues; }
89 void setMaxNumberOfValues(std::size_t maxNum);
92 bool hasValueLabels()
const;
94 std::string valueLabel(std::size_t element)
const;
96 void setValueLabel(std::size_t element,
const std::string& elabel);
98 void setCommonValueLabel(
const std::string& elabel);
100 bool usingCommonLabel()
const;
104 void setLockType(smtk::resource::LockType val) { m_lockType = val; }
105 smtk::resource::LockType lockType()
const {
return m_lockType; }
110 smtk::resource::Links::RoleType
role()
const {
return m_role; }
116 void setRole(
const smtk::resource::Links::RoleType& role) { m_role = role; }
122 bool holdReference()
const {
return m_holdReference; }
129 bool onlyResources()
const {
return m_onlyResources; }
147 return (m_itemDefs.find(itemName) != m_itemDefs.end());
163 typename smtk::internal::shared_ptr_type<T>::SharedPointerType addItemDefinition(
164 const std::string& idName)
167 typename SharedTypes::SharedPointerType item;
170 if (this->hasChildItemDefinition(idName))
175 item = SharedTypes::RawPointerType::New(idName);
176 m_itemDefs[item->name()] = item;
181 static constexpr std::size_t s_invalidIndex = SIZE_MAX;
201 std::size_t addConditional(
202 const std::string& resourceQuery,
203 const std::string& componentQuery,
204 const std::vector<std::string>& itemNames);
207 bool hasChildItemDefinition(std::size_t ith,
const std::string& itemName);
215 return m_conditionalItemNames;
219 const std::vector<std::string>& conditionalItems(std::size_t ith)
const;
259 void applyCategories(
263 void setUnitsSystem(
const shared_ptr<units::System>& unitsSystem)
override;
265 bool m_useCommonLabel;
266 std::vector<std::string> m_valueLabels;
268 std::size_t m_numberOfRequiredValues;
269 std::size_t m_maxNumberOfValues;
270 std::multimap<std::string, std::string> m_acceptable;
271 std::multimap<std::string, std::string> m_rejected;
272 smtk::resource::LockType m_lockType;
273 smtk::resource::Links::RoleType m_role;
274 bool m_holdReference;
275 bool m_enforcesCategories =
false;
278 std::map<std::string, smtk::attribute::ItemDefinitionPtr> m_itemDefs;
280 std::vector<std::string> m_resourceQueries;
282 std::vector<std::string> m_componentQueries;
284 std::vector<std::vector<std::string>> m_conditionalItemNames;
287 bool m_onlyResources;
296 const std::string& itemName)
305 std::find(m_conditionalItemNames[ith].begin(), m_conditionalItemNames[ith].end(), itemName) !=
306 m_conditionalItemNames[ith].end());
The main namespace for the Simulation Modeling Tool Kit (SMTK).
Definition: doc.h:33
Type
Definition: Item.h:56
Stores the definition of an attribute.
Definition: Definition.h:45
virtual void setOnlyResources(bool choice)
Set/Get a flag to determine whether the ReferenceItem should only hold references.
Definition: ReferenceItemDefinition.h:128
const std::vector< std::string > & componentQueries() const
Return the vector of component queries of all conditionals.
Definition: ReferenceItemDefinition.h:225
const std::map< std::string, smtk::attribute::ItemDefinitionPtr > & childrenItemDefinitions() const
Return the map of children item definitions.
Definition: ReferenceItemDefinition.h:139
Definition: Categories.h:146
smtk::shared_ptr< const smtk::resource::PersistentObject > ConstPersistentObjectPtr
Definition: PublicPointerDefs.h:294
Definition: ItemDefinition.h:42
smtk::resource::Links::RoleType role() const
Get the reference's role when generating links between the containing attribute and the reference ite...
Definition: ReferenceItemDefinition.h:110
Definition: PublicPointerDefs.h:756
bool hasChildItemDefinition(const std::string &itemName) const
returns true if this item has a child item definition of itemName
Definition: ReferenceItemDefinition.h:145
A definition for attribute items that store smtk::resource::PersistentObjectPtr as values.
Definition: ReferenceItemDefinition.h:40
Definition: ItemDefinition.h:52
The base class for items that hold information inside an attribute.
Definition: Item.h:47
std::size_t numberOfConditionals() const
Return the number of conditionals.
Definition: ReferenceItemDefinition.h:210
std::size_t numberOfChildrenItemDefinitions() const
Return the number of children item definitions.
Definition: ReferenceItemDefinition.h:135
void setHoldReference(bool choice)
Set/Get a flag to determine whether the ReferenceItem should keep an assigned reference in memory (i....
Definition: ReferenceItemDefinition.h:121
#define smtkTypeMacro(...)
Add typedefs to a class for identifcation.
Definition: SharedFromThis.h:128
Hold associations that link resources or components as an attribute value.
Definition: ReferenceItem.h:51
void setLockType(smtk::resource::LockType val)
Set/Get the reference resource's lock type (Read/Write/DoNotLock) for read lock, write lock or bypass...
Definition: ReferenceItemDefinition.h:104
Definition: ValueItemDefinition.h:41
void setRole(const smtk::resource::Links::RoleType &role)
Set the reference's role when generating links between the containing attribute and the reference ite...
Definition: ReferenceItemDefinition.h:116
smtk::shared_ptr< smtk::attribute::ReferenceItemDefinition > ReferenceItemDefinitionPtr
Definition: PublicPointerDefs.h:540
#define smtkSuperclassMacro(...)
Add a typedef to the superclass of this class.
Definition: SharedFromThis.h:147
const std::vector< std::string > & resourceQueries() const
Return the vector of resource queries of all conditionals.
Definition: ReferenceItemDefinition.h:222
std::string typeName()
Return the name of a class.
Definition: TypeName.h:289
An abstract base class for SMTK resources.
Definition: Resource.h:72
Represent a (possibly composite) value according to a definition.
Definition: Attribute.h:50
Represents the category constraints associated with an Attribute, Attribute Definition,...
Definition: Categories.h:32
const std::vector< std::vector< std::string > > & conditionalInformation() const
Return the conditional item name information.
Definition: ReferenceItemDefinition.h:213
Component is the base class for records stored in an smtk::resource::Resource.
Definition: Component.h:43
smtk::shared_ptr< smtk::resource::PersistentObject > PersistentObjectPtr
Definition: PublicPointerDefs.h:292
smtk::shared_ptr< smtk::attribute::Item > ItemPtr
Definition: PublicPointerDefs.h:474
smtk::shared_ptr< smtk::attribute::ItemDefinition > ItemDefinitionPtr
Definition: PublicPointerDefs.h:480