SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
11 #ifndef smtk_attribute_Item_h
12 #define smtk_attribute_Item_h
14 #include "smtk/CoreExports.h"
17 #include "smtk/attribute/Categories.h"
18 #include "smtk/attribute/CopyAssignmentOptions.h"
19 #include "smtk/attribute/SearchStyle.h"
20 #include "smtk/common/Status.h"
47 class SMTKCORE_EXPORT
Item :
public smtk::enable_shared_from_this<Item>
58 typedef std::function<
59 bool(
const Item*,
bool includeCatagories,
bool includeReadAccess,
unsigned int readAccessLevel)>
83 std::string name()
const;
84 std::string label()
const;
100 bool isValid(
bool useActiveCategories =
true)
const;
101 bool isValid(
const std::set<std::string>& categories)
const
103 return (!this->isEnabled()) || this->isIgnored() || this->isValidInternal(
true, categories);
119 bool includeCatagories =
true,
120 bool includeReadAccess =
false,
121 unsigned int readAccessLevel = 0)
const;
129 virtual bool defaultIsRelevant(
130 bool includeCatagories,
131 bool includeReadAccess,
132 unsigned int readAccessLevel)
const;
156 bool activeChildren =
true)
159 (void)activeChildren;
163 template<
typename DefType>
164 std::shared_ptr<const DefType> definitionAs()
const
166 return std::dynamic_pointer_cast<const DefType>(m_definition);
182 int subGroupPosition()
const;
187 std::string path(
const std::string& sep =
"/")
const;
191 bool isOptional()
const;
198 bool isEnabled()
const;
203 void setIsEnabled(
bool isEnabledValue) { m_isEnabled = isEnabledValue; }
232 unsigned int advanceLevel(
int mode = 0)
const;
233 void setLocalAdvanceLevel(
int mode,
unsigned int level);
234 unsigned int localAdvanceLevel(
int mode = 0)
const
236 return (mode == 1 ? m_localAdvanceLevel[1] : m_localAdvanceLevel[0]);
241 void unsetLocalAdvanceLevel(
int mode = 0);
244 bool hasLocalAdvanceLevelInfo(
int mode = 0)
const
246 return (mode == 1 ? m_hasLocalAdvanceLevelInfo[1] : m_hasLocalAdvanceLevelInfo[0]);
251 m_userData[key] = value;
254 void clearUserData(
const std::string& key) { m_userData.erase(key); }
255 void clearAllUserData() { m_userData.clear(); }
257 virtual void reset();
261 virtual bool rotate(std::size_t fromPosition, std::size_t toPosition);
281 virtual Status assign(
285 virtual Status assign(
304 static Item::Type string2Type(
const std::string& s);
308 Item(
Item* owningItem,
int myPosition,
int mySubGroupPosition);
316 bool rotateVector(std::vector<T>& v, std::size_t fromPosition, std::size_t toPosition);
319 virtual bool isValidInternal(
bool useCategories,
const std::set<std::string>& categories)
324 int m_subGroupPosition;
328 std::map<std::string, smtk::simulation::UserDataPtr> m_userData;
329 RelevanceFunc m_customIsRelevant =
nullptr;
332 bool m_hasLocalAdvanceLevelInfo[2];
333 unsigned int m_localAdvanceLevel[2];
334 bool m_forceRequired;
339 std::map<std::string, smtk::simulation::UserDataPtr>::const_iterator it = m_userData.find(key);
346 return smtk::dynamic_pointer_cast<T>(this->
find(iname, style));
352 return smtk::dynamic_pointer_cast<const T>(this->
find(iname, style));
356 bool Item::rotateVector(std::vector<T>& v, std::size_t fromPosition, std::size_t toPosition)
358 if (fromPosition == toPosition)
363 std::size_t lastPosition = v.size() - 1;
364 if ((fromPosition > lastPosition) || (toPosition > lastPosition))
369 auto first = v.begin();
370 auto middle = v.begin();
371 auto last = v.begin();
372 if (fromPosition < toPosition)
374 first += fromPosition;
375 last += toPosition + 1;
376 middle += fromPosition + 1;
381 last += fromPosition + 1;
382 middle += fromPosition;
384 std::rotate(first, middle, last);
The main namespace for the Simulation Modeling Tool Kit (SMTK).
Definition: doc.h:33
Type
Definition: Item.h:62
Stores the definition of an attribute.
Definition: Definition.h:47
Class used to specify copy and assignment options.
Definition: CopyAssignmentOptions.h:272
SearchStyle
How should searches for items be conducted?
Definition: SearchStyle.h:24
void detachOwningAttribute()
This should be used only by attributes.
Definition: Item.h:267
virtual void visitChildren(std::function< void(smtk::attribute::ItemPtr, bool)> visitor, bool activeChildren=true)
visitChildren Invoke a function on each (or, if findInActiveChildren is true, each active) child item...
Definition: Item.h:154
smtk::shared_ptr< smtk::simulation::UserData > UserDataPtr
Definition: PublicPointerDefs.h:678
void setForceRequired(bool val)
Controls if an item should be forced to be required regardless of its local enable property.
Definition: Item.h:215
void setIsEnabled(bool isEnabledValue)
Set the instance's local enabled state.
Definition: Item.h:203
virtual void detachOwningResource()
Release the item's dependency on its parent attribute's Resource.
Definition: Item.h:264
@ MeshEntityType
Needed for backward compatibility w/r XML/JSON formats < 4.0.
Definition: Item.h:74
void setCustomIsRelevant(RelevanceFunc func)
Set and Get Methods for specifying a custom isRelevant function.
Definition: Item.h:109
smtk::shared_ptr< const smtk::attribute::ItemDefinition > ConstItemDefinitionPtr
Definition: PublicPointerDefs.h:482
Log messages for later presentation to a user or a file.
Definition: Logger.h:94
std::function< bool(const Item *, bool includeCatagories, bool includeReadAccess, unsigned int readAccessLevel)> RelevanceFunc
Typedef for custom relevance functions.
Definition: Item.h:60
bool localEnabledState() const
Return the state of the instance's isEnabled state.
Definition: Item.h:201
@ AttributeRefType
Needed for backward compatibility w/r XML/JSON formats < 4.0.
Definition: Item.h:64
void setIsIgnored(bool val)
Controls if an item should be ignored.
Definition: Item.h:298
bool isIgnored() const
Controls if an item should be ignored.
Definition: Item.h:300
A definition for attribute items that store smtk::resource::PersistentObjectPtr as values.
Definition: ReferenceItemDefinition.h:40
void detachOwningItem()
This should only be called by the item that owns this one.
Definition: Item.h:270
The base class for items that hold information inside an attribute.
Definition: Item.h:47
A return value for methods that need to indicate both success/failure and modification/stasis.
Definition: Status.h:30
smtk::shared_ptr< smtk::attribute::Attribute > AttributePtr
Definition: PublicPointerDefs.h:463
@ RECURSIVE_ACTIVE
Recursively search for an active item.
Definition: SearchStyle.h:32
smtk::shared_ptr< const smtk::attribute::Item > ConstItemPtr
Definition: PublicPointerDefs.h:476
Definition: ValueItemDefinition.h:41
T::Ptr findAs(const std::string &name, SearchStyle style=RECURSIVE_ACTIVE)
return a child item that matches name and satisfies the SearchStyle
Definition: Item.h:344
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:33
bool isValid(const std::set< std::string > &categories) const
tests the validity of an item
Definition: Item.h:101
RelevanceFunc customIsRelevant() const
Set and Get Methods for specifying a custom isRelevant function.
Definition: Item.h:110
smtk::shared_ptr< smtk::attribute::Item > ItemPtr
Definition: PublicPointerDefs.h:474
Macros for dealing with shared-pointer classes.
A GroupItemDefinition represents a collection of Item Definitions.
Definition: GroupItemDefinition.h:32
#define smtkTypeMacroBase(...)
Add typedefs to a class for identifcation.
Definition: SharedFromThis.h:131
int position() const
Position is the item's location w/r to the owning item if not null or the owning attribute.
Definition: Item.h:178
smtk::attribute::ItemPtr find(const std::string &name, SearchStyle style=RECURSIVE_ACTIVE)
return a child item that matches name and satisfies the SearchStyle
Definition: Item.cxx:149
bool forceRequired() const
Controls if an item should be forced to be required regardless of its local enable property.
Definition: Item.h:216