Commit 0bb07aa6 authored by Bob Obara's avatar Bob Obara

ENH:Added CastTo Methods for Wrapping

Also made all Item constructors and setDefinition methods protected
parent 7ad9b5c7
......@@ -200,4 +200,4 @@ namespace smtk
};
};
#endif /* __smtk_PublicPointerDefs_h */
\ No newline at end of file
#endif /* __smtk_PublicPointerDefs_h */
......@@ -38,15 +38,18 @@ namespace smtk
{
class Attribute;
class AttributeRefItemDefinition;
class ValueItemDefinition;
class SMTKCORE_EXPORT AttributeRefItem : public Item
{
friend class Attribute;
friend class AttributeRefItemDefinition;
friend class ValueItemDefinition;
public:
AttributeRefItem(Attribute *owningAttribute, int itemPosition);
AttributeRefItem(Item *owningItem, int myPosition, int mySubGroupPosition);
// This method is for wrapping code. C++ developers should use smtk::dynamicCastPointer
static smtk::AttributeRefItemPtr CastTo(const smtk::AttributeItemPtr &p)
{return smtk::dynamic_pointer_cast<AttributeRefItem>(p);}
virtual ~AttributeRefItem();
virtual Item::Type type() const;
virtual bool setDefinition(smtk::ConstAttributeItemDefinitionPtr def);
std::size_t numberOfValues() const
{return this->m_values.size();}
bool setNumberOfValues(std::size_t newSize);
......@@ -67,6 +70,9 @@ namespace smtk
virtual void unset(int element=0);
protected:
AttributeRefItem(Attribute *owningAttribute, int itemPosition);
AttributeRefItem(Item *owningItem, int myPosition, int mySubGroupPosition);
virtual bool setDefinition(smtk::ConstAttributeItemDefinitionPtr def);
void clearAllReferences();
std::vector<WeakAttributePtr>m_values;
private:
......
......@@ -45,6 +45,11 @@ namespace smtk
static smtk::AttributeRefItemDefinitionPtr New(const std::string &myName)
{ return smtk::AttributeRefItemDefinitionPtr(new AttributeRefItemDefinition(myName));}
// This method is for wrapping code. C++ developers should use smtk::dynamicCastPointer
static smtk::AttributeRefItemDefinitionPtr
CastTo(const smtk::AttributeItemDefinitionPtr &p)
{return smtk::dynamic_pointer_cast<AttributeRefItemDefinition>(p);}
virtual ~AttributeRefItemDefinition();
virtual Item::Type type() const;
......
......@@ -40,11 +40,13 @@ namespace smtk
class DirectoryItemDefinition;
class SMTKCORE_EXPORT DirectoryItem : public Item
{
friend class DirectoryItemDefinition;
public:
DirectoryItem(Attribute *owningAttribute, int itemPosition);
DirectoryItem(Item *owningItem, int position, int subGroupPosition);
// This method is for wrapping code. C++ developers should use smtk::dynamicCastPointer
static smtk::DirectoryItemPtr CastTo(const smtk::AttributeItemPtr &p)
{return smtk::dynamic_pointer_cast<DirectoryItem>(p);}
virtual ~DirectoryItem();
virtual bool setDefinition(smtk::ConstAttributeItemDefinitionPtr vdef);
virtual Item::Type type() const;
bool shouldBeRelative() const;
bool shouldExist() const;
......@@ -69,6 +71,9 @@ namespace smtk
{this->m_isSet[element] = false;}
protected:
DirectoryItem(Attribute *owningAttribute, int itemPosition);
DirectoryItem(Item *owningItem, int position, int subGroupPosition);
virtual bool setDefinition(smtk::ConstAttributeItemDefinitionPtr vdef);
std::vector<std::string>m_values;
std::vector<bool> m_isSet;
private:
......
......@@ -44,6 +44,11 @@ namespace smtk
public:
static smtk::DirectoryItemDefinitionPtr New(const std::string &myName)
{ return smtk::DirectoryItemDefinitionPtr(new DirectoryItemDefinition(myName));}
// This method is for wrapping code. C++ developers should use smtk::dynamicCastPointer
static smtk::DirectoryItemDefinitionPtr CastTo(const smtk::AttributeItemDefinitionPtr &p)
{return smtk::dynamic_pointer_cast<DirectoryItemDefinition>(p);}
virtual ~DirectoryItemDefinition();
virtual Item::Type type() const;
......
......@@ -41,11 +41,15 @@ namespace smtk
{
friend class DoubleItemDefinition;
public:
DoubleItem(Attribute *owningAttribute, int itemPosition);
DoubleItem(Item *owningItem, int myPosition, int mySubGroupPosition);
// This method is for wrapping code. C++ developers should use smtk::dynamicCastPointer
static smtk::DoubleItemPtr CastTo(const smtk::AttributeItemPtr &p)
{return smtk::dynamic_pointer_cast<DoubleItem>(p);}
virtual ~DoubleItem();
virtual Item::Type type() const;
protected:
DoubleItem(Attribute *owningAttribute, int itemPosition);
DoubleItem(Item *owningItem, int myPosition, int mySubGroupPosition);
private:
......
......@@ -39,6 +39,11 @@ namespace smtk
public:
static smtk::DoubleItemDefinitionPtr New(const std::string &myName)
{ return smtk::DoubleItemDefinitionPtr(new DoubleItemDefinition(myName));}
// This method is for wrapping code. C++ developers should use smtk::dynamicCastPointer
static smtk::DoubleItemDefinitionPtr CastTo(const smtk::AttributeItemDefinitionPtr &p)
{return smtk::dynamic_pointer_cast<DoubleItemDefinition>(p);}
virtual ~DoubleItemDefinition();
virtual Item::Type type() const;
virtual smtk::AttributeItemPtr buildItem(Attribute *owningAttribute,
......
......@@ -40,11 +40,13 @@ namespace smtk
class FileItemDefinition;
class SMTKCORE_EXPORT FileItem : public Item
{
friend class FileItemDefinition;
public:
FileItem(Attribute *owningAttribute, int itemPosition);
FileItem(Item *owningItem, int position, int subGroupPosition);
// This method is for wrapping code. C++ developers should use smtk::dynamicCastPointer
static smtk::FileItemPtr CastTo(const smtk::AttributeItemPtr &p)
{return smtk::dynamic_pointer_cast<FileItem>(p);}
virtual ~FileItem();
virtual bool setDefinition(smtk::ConstAttributeItemDefinitionPtr vdef);
virtual Item::Type type() const;
bool shouldBeRelative() const;
bool shouldExist() const;
......@@ -69,6 +71,9 @@ namespace smtk
{this->m_isSet[element] = false;}
protected:
FileItem(Attribute *owningAttribute, int itemPosition);
FileItem(Item *owningItem, int position, int subGroupPosition);
virtual bool setDefinition(smtk::ConstAttributeItemDefinitionPtr vdef);
std::vector<std::string>m_values;
std::vector<bool> m_isSet;
private:
......
......@@ -45,6 +45,10 @@ namespace smtk
static smtk::FileItemDefinitionPtr New(const std::string &myName)
{ return smtk::FileItemDefinitionPtr(new FileItemDefinition(myName));}
// This method is for wrapping code. C++ developers should use smtk::dynamicCastPointer
static smtk::FileItemDefinitionPtr CastTo(const smtk::AttributeItemDefinitionPtr &p)
{return smtk::dynamic_pointer_cast<FileItemDefinition>(p);}
virtual ~FileItemDefinition();
virtual Item::Type type() const;
......
......@@ -39,11 +39,12 @@ namespace smtk
{
friend class GroupItemDefinition;
public:
GroupItem(Attribute *owningAttribute, int itemPosition);
GroupItem(Item *owningItem, int myPosition, int mySubGroupPosition);
// This method is for wrapping code. C++ developers should use smtk::dynamicCastPointer
static smtk::GroupItemPtr CastTo(const smtk::AttributeItemPtr &p)
{return smtk::dynamic_pointer_cast<GroupItem>(p);}
virtual ~GroupItem();
virtual Item::Type type() const;
virtual bool setDefinition(smtk::ConstAttributeItemDefinitionPtr def);
std::size_t numberOfRequiredGroups() const;
std::size_t numberOfGroups() const
{return this->m_items.size();}
......@@ -66,6 +67,9 @@ namespace smtk
virtual void reset();
protected:
GroupItem(Attribute *owningAttribute, int itemPosition);
GroupItem(Item *owningItem, int myPosition, int mySubGroupPosition);
virtual bool setDefinition(smtk::ConstAttributeItemDefinitionPtr def);
// This method will detach all of the items directly owned by
// this group
void detachAllItems();
......
......@@ -44,6 +44,10 @@ namespace smtk
static smtk::GroupItemDefinitionPtr New(const std::string &myName)
{ return smtk::GroupItemDefinitionPtr(new GroupItemDefinition(myName));}
// This method is for wrapping code. C++ developers should use smtk::dynamicCastPointer
static smtk::GroupItemDefinitionPtr CastTo(const smtk::AttributeItemDefinitionPtr &p)
{return smtk::dynamic_pointer_cast<GroupItemDefinition>(p);}
virtual ~GroupItemDefinition();
virtual Item::Type type() const;
std::size_t numberOfItemDefinitions() const
......
......@@ -41,11 +41,15 @@ namespace smtk
{
friend class IntItemDefinition;
public:
IntItem(Attribute *owningAttribute, int itemPosition);
IntItem(Item *owningItem, int myPosition, int mySubGroupPosition);
// This method is for wrapping code. C++ developers should use smtk::dynamicCastPointer
static smtk::IntItemPtr CastTo(const smtk::AttributeItemPtr &p)
{return smtk::dynamic_pointer_cast<IntItem>(p);}
virtual ~IntItem();
virtual Item::Type type() const;
protected:
IntItem(Attribute *owningAttribute, int itemPosition);
IntItem(Item *owningItem, int myPosition, int mySubGroupPosition);
private:
......
......@@ -40,6 +40,10 @@ namespace smtk
static smtk::IntItemDefinitionPtr New(const std::string &myName)
{ return smtk::IntItemDefinitionPtr(new IntItemDefinition(myName));}
// This method is for wrapping code. C++ developers should use smtk::dynamicCastPointer
static smtk::IntItemDefinitionPtr CastTo(const smtk::AttributeItemDefinitionPtr &p)
{return smtk::dynamic_pointer_cast<IntItemDefinition>(p);}
virtual ~IntItemDefinition();
virtual Item::Type type() const;
virtual smtk::AttributeItemPtr buildItem(Attribute *owningAttribute,
......
......@@ -40,32 +40,33 @@ namespace smtk
{
class ItemDefinition;
class GroupItem;
class GroupItemDefinition;
class Attribute;
class Definition;
class SMTKCORE_EXPORT Item
{
friend class Definition;
friend class GroupItemDefinition;
public:
enum Type
{
ATTRIBUTE_REF,
DOUBLE,
GROUP,
INT,
STRING,
VOID,
FILE,
DIRECTORY,
COLOR,
NUMBER_OF_TYPES
};
enum Type
{
ATTRIBUTE_REF,
DOUBLE,
GROUP,
INT,
STRING,
VOID,
FILE,
DIRECTORY,
COLOR,
NUMBER_OF_TYPES
};
Item(Attribute *owningAttribute, int itemPosition);
Item(Item *owningItem, int myPosition, int mySubGroupPOsition);
virtual ~Item();
std::string name() const;
std::string label() const;
virtual Item::Type type() const = 0;
virtual bool setDefinition(smtk::ConstAttributeItemDefinitionPtr def);
smtk::ConstAttributeItemDefinitionPtr definition() const
{return this->m_definition;}
......@@ -120,17 +121,20 @@ namespace smtk
static std::string type2String(Item::Type t);
static Item::Type string2Type(const std::string &s);
protected:
Attribute *m_attribute;
Item *m_owningItem;
int m_position;
int m_subGroupPosition;
bool m_isEnabled;
mutable std::string m_tempString;
smtk::ConstAttributeItemDefinitionPtr m_definition;
std::map<std::string, smtk::UserDataPtr > m_userData;
protected:
Item(Attribute *owningAttribute, int itemPosition);
Item(Item *owningItem, int myPosition, int mySubGroupPOsition);
virtual bool setDefinition(smtk::ConstAttributeItemDefinitionPtr def);
Attribute *m_attribute;
Item *m_owningItem;
int m_position;
int m_subGroupPosition;
bool m_isEnabled;
mutable std::string m_tempString;
smtk::ConstAttributeItemDefinitionPtr m_definition;
std::map<std::string, smtk::UserDataPtr > m_userData;
private:
};
//----------------------------------------------------------------------------
inline smtk::UserDataPtr Item::userData(const std::string &key) const
......
......@@ -48,7 +48,6 @@ namespace smtk
friend class smtk::attribute::Definition;
friend class smtk::attribute::GroupItemDefinition;
public:
ItemDefinition(const std::string &myname);
virtual ~ItemDefinition();
const std::string &name() const
{ return this->m_name;}
......@@ -116,6 +115,7 @@ namespace smtk
int position,
int subGroupPosition) const = 0;
protected:
ItemDefinition(const std::string &myname);
virtual void updateCategories();
int m_version;
bool m_isOptional;
......
......@@ -41,11 +41,15 @@ namespace smtk
{
friend class StringItemDefinition;
public:
StringItem(Attribute *owningAttribute, int itemPosition);
StringItem(Item *owningItem, int myPosition, int mySubGroupPosition);
// This method is for wrapping code. C++ developers should use smtk::dynamicCastPointer
static smtk::StringItemPtr CastTo(const smtk::AttributeItemPtr &p)
{return smtk::dynamic_pointer_cast<StringItem>(p);}
virtual ~StringItem();
virtual Item::Type type() const;
protected:
StringItem(Attribute *owningAttribute, int itemPosition);
StringItem(Item *owningItem, int myPosition, int mySubGroupPosition);
private:
......
......@@ -40,6 +40,10 @@ namespace smtk
static smtk::StringItemDefinitionPtr New(const std::string &myName)
{ return smtk::StringItemDefinitionPtr(new StringItemDefinition(myName));}
// This method is for wrapping code. C++ developers should use smtk::dynamicCastPointer
static smtk::StringItemDefinitionPtr CastTo(const smtk::AttributeItemDefinitionPtr &p)
{return smtk::dynamic_pointer_cast<StringItemDefinition>(p);}
virtual ~StringItemDefinition();
virtual Item::Type type() const;
virtual smtk::AttributeItemPtr buildItem(Attribute *owningAttribute,
......
......@@ -42,14 +42,15 @@ namespace smtk
{
public:
friend class ValueItemDefinition;
ValueItem(Attribute *owningAttribute, int itemPosition);
ValueItem(Item *owningItem, int myPosition, int mySubGroupPosition);
// This method is for wrapping code. C++ developers should use smtk::dynamicCastPointer
static smtk::ValueItemPtr CastTo(const smtk::AttributeItemPtr &p)
{return smtk::dynamic_pointer_cast<ValueItem>(p);}
virtual ~ValueItem();
std::size_t numberOfValues() const
{return this->m_isSet.size();}
int numberOfRequiredValues() const;
virtual bool setDefinition(smtk::ConstAttributeItemDefinitionPtr def);
bool allowsExpressions() const;
bool isExpression(int elementIndex=0) const
{ return (this->expression(elementIndex) != NULL);}
......@@ -87,6 +88,9 @@ namespace smtk
{return this->m_expressions[elementIndex];}
protected:
ValueItem(Attribute *owningAttribute, int itemPosition);
ValueItem(Item *owningItem, int myPosition, int mySubGroupPosition);
virtual bool setDefinition(smtk::ConstAttributeItemDefinitionPtr def);
virtual void updateDiscreteValue(int elementIndex) = 0;
std::vector<int> m_discreteIndices;
std::vector<bool> m_isSet;
......
......@@ -52,6 +52,10 @@ namespace smtk
ValueItemDefinition(const std::string &myname);
virtual ~ValueItemDefinition();
// This method is for wrapping code. C++ developers should use smtk::dynamicCastPointer
static smtk::ValueItemDefinitionPtr CastTo(const smtk::AttributeItemDefinitionPtr &p)
{return smtk::dynamic_pointer_cast<ValueItemDefinition>(p);}
const std::string &units() const
{ return this->m_units;}
void setUnits(const std::string &newUnits)
......
......@@ -46,10 +46,7 @@ namespace smtk
typedef DataT DataType;
typedef ValueItemDefinitionTemplate<DataType> DefType;
ValueItemTemplate(Attribute *owningAttribute, int itemPosition);
ValueItemTemplate(Item *owningItem, int myPosition, int mySubGroupPosition);
virtual ~ValueItemTemplate() {}
virtual bool setDefinition(smtk::ConstAttributeItemDefinitionPtr vdef);
std::size_t numberOfValues() const
{return this->m_values.size();}
virtual bool setNumberOfValues(std::size_t newSize);
......@@ -68,6 +65,9 @@ namespace smtk
bool setToDefault(int element=0);
protected:
ValueItemTemplate(Attribute *owningAttribute, int itemPosition);
ValueItemTemplate(Item *owningItem, int myPosition, int mySubGroupPosition);
virtual bool setDefinition(smtk::ConstAttributeItemDefinitionPtr vdef);
virtual void updateDiscreteValue(int element);
std::vector<DataT> m_values;
private:
......
......@@ -39,14 +39,19 @@ namespace smtk
class VoidItemDefinition;
class SMTKCORE_EXPORT VoidItem : public Item
{
friend class VoidItemDefinition;
public:
VoidItem(Attribute *owningAttribute, int itemPosition);
VoidItem(Item *owningItem, int myPosition, int mySubGroupPosition);
// This method is for wrapping code. C++ developers should use smtk::dynamicCastPointer
static smtk::VoidItemPtr CastTo(const smtk::AttributeItemPtr &p)
{return smtk::dynamic_pointer_cast<VoidItem>(p);}
virtual ~VoidItem();
virtual Item::Type type() const;
virtual bool setDefinition(smtk::ConstAttributeItemDefinitionPtr def);
protected:
VoidItem(Attribute *owningAttribute, int itemPosition);
VoidItem(Item *owningItem, int myPosition, int mySubGroupPosition);
virtual bool setDefinition(smtk::ConstAttributeItemDefinitionPtr def);
private:
};
}
......
......@@ -43,6 +43,10 @@ namespace smtk
static smtk::VoidItemDefinitionPtr New(const std::string &myName)
{ return smtk::VoidItemDefinitionPtr(new VoidItemDefinition(myName));}
// This method is for wrapping code. C++ developers should use smtk::dynamicCastPointer
static smtk::VoidItemDefinitionPtr CastTo(const smtk::AttributeItemDefinitionPtr &p)
{return smtk::dynamic_pointer_cast<VoidItemDefinition>(p);}
virtual ~VoidItemDefinition();
virtual Item::Type type() const;
virtual smtk::AttributeItemPtr buildItem(Attribute *owningAttribute,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment