SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
DateTimeItem.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 DateTimeItem.h -
11 // .SECTION Description
12 // .SECTION See Also
13 
14 #ifndef smtk_attribute_DateTimeItem_h
15 #define smtk_attribute_DateTimeItem_h
16 
17 #include "smtk/CoreExports.h"
18 #include "smtk/attribute/CopyAssignmentOptions.h"
19 #include "smtk/attribute/Item.h"
20 #include "smtk/common/DateTimeZonePair.h"
21 #include <vector>
22 
23 namespace smtk
24 {
25 namespace attribute
26 {
27 class Attribute;
28 class DateTimeItemDefinition;
29 class SMTKCORE_EXPORT DateTimeItem : public Item
30 {
31  friend class DateTimeItemDefinition;
32 
33 public:
35  ~DateTimeItem() override;
36  Item::Type type() const override;
37 
38  std::size_t numberOfValues() const { return m_values.size(); }
39  bool setNumberOfValues(std::size_t newSize);
40  std::size_t numberOfRequiredValues() const;
41  ::smtk::common::DateTimeZonePair value(std::size_t element = 0) const
42  {
43  return m_values[element];
44  }
45  bool setValue(const ::smtk::common::DateTimeZonePair& val) { return this->setValue(0, val); }
46  bool setValue(std::size_t element, const ::smtk::common::DateTimeZonePair& val);
47  void reset() override;
48  virtual bool setToDefault(std::size_t elementIndex = 0);
49  // Returns true if there is a default defined and the item is curently set to it
50  virtual bool isUsingDefault(std::size_t elementIndex) const;
51  // This method tests all of the values of the items w/r the default value
52  virtual bool isUsingDefault() const;
53  bool hasDefault() const;
54  virtual bool isSet(std::size_t element = 0) const
55  {
56  return m_isSet.size() > element ? m_isSet[element] : false;
57  }
58 
59  virtual void unset(std::size_t element = 0)
60  {
61  assert(m_isSet.size() > element);
62  m_isSet[element] = false;
63  }
64 
65  // Assigns this item to be equivalent to another. Options are processed by derived item classes.
66  // The options are defined in CopyAssignmentOptions.h. Returns true if success and false if a problem occurred.
67  using Item::assign;
68  bool assign(
69  const smtk::attribute::ConstItemPtr& sourceItem,
70  const CopyAssignmentOptions& options,
71  smtk::io::Logger& logger) override;
72 
73 protected:
74  DateTimeItem(Attribute* owningAttribute, int itemPosition);
75  DateTimeItem(Item* owningItem, int myPosition, int mySubGroupPosition);
76  bool setDefinition(smtk::attribute::ConstItemDefinitionPtr def) override;
77  ConstDateTimeItemDefinitionPtr itemDefinition() const;
78  bool isValidInternal(bool useCategories, const std::set<std::string>& categories) const override;
79  std::vector<::smtk::common::DateTimeZonePair> m_values;
80  std::vector<bool> m_isSet;
81 
82 private:
83 };
84 } // namespace attribute
85 } // namespace smtk
86 
87 #endif /* smtk_attribute_DateTimeItem_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
smtk::attribute::CopyAssignmentOptions
Class used to specify copy and assignment options.
Definition: CopyAssignmentOptions.h:211
smtk::attribute::DateTimeItemDefinition
Definition: DateTimeItemDefinition.h:25
smtk::attribute::Item::assign
virtual bool assign(const smtk::attribute::ConstItemPtr &sourceItem, unsigned int options)
Assigns this item to be equivalent to another.
Definition: Item.cxx:292
smtk::attribute::ConstItemDefinitionPtr
smtk::shared_ptr< const smtk::attribute::ItemDefinition > ConstItemDefinitionPtr
Definition: PublicPointerDefs.h:475
smtk::io::Logger
Log messages for later presentation to a user or a file.
Definition: Logger.h:95
smtk::attribute::ConstDateTimeItemDefinitionPtr
smtk::shared_ptr< const smtk::attribute::DateTimeItemDefinition > ConstDateTimeItemDefinitionPtr
Definition: PublicPointerDefs.h:547
smtk::attribute::Item
Definition: Item.h:43
smtkTypeMacro
#define smtkTypeMacro(...)
Add typedefs to a class for identifcation.
Definition: SharedFromThis.h:51
smtk::attribute::ConstItemPtr
smtk::shared_ptr< const smtk::attribute::Item > ConstItemPtr
Definition: PublicPointerDefs.h:469
smtk::attribute::DateTimeItem
Definition: DateTimeItem.h:29
smtk::common::DateTimeZonePair
Definition: DateTimeZonePair.h:24
smtk::attribute::Attribute
Represent a (possibly composite) value according to a definition.
Definition: Attribute.h:49