Commit e6356e62 authored by Bob Obara's avatar Bob Obara

ENH: Cleaned up setting definitions

Also added tests and fixed issues with Expressions
parent 7c84cc08
......@@ -27,6 +27,7 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include "attribute/Cluster.h"
#include "attribute/Component.h"
#include "attribute/Definition.h"
#include <iostream>
using namespace slctk::attribute;
//----------------------------------------------------------------------------
Attribute::Attribute(const std::string &myName, slctk::AttributeClusterPtr myCluster,
......@@ -38,6 +39,7 @@ Attribute::Attribute(const std::string &myName, slctk::AttributeClusterPtr myClu
//----------------------------------------------------------------------------
Attribute::~Attribute()
{
std::cout << "Deleting Attribute " << this->name() << "\n";
this->removeAllAssociations();
this->removeAllComponents();
}
......
......@@ -30,15 +30,31 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
using namespace slctk::attribute;
//----------------------------------------------------------------------------
AttributeReferenceComponent::
AttributeReferenceComponent(const AttributeReferenceComponentDefinition *def):
ValueComponent(def)
AttributeReferenceComponent::AttributeReferenceComponent()
{
}
//----------------------------------------------------------------------------
bool AttributeReferenceComponent::
setDefinition(slctk::ConstAttributeComponentDefinitionPtr adef)
{
// Note that we do a dynamic cast here since we don't
// know if the proper definition is being passed
const AttributeReferenceComponentDefinition *def =
dynamic_cast<const AttributeReferenceComponentDefinition *>(adef.get());
// Call the parent's set definition - similar to constructor calls
// we call from base to derived
if ((def == NULL) || (!Component::setDefinition(adef)))
{
return false;
}
int n = def->numberOfValues();
if (n)
{
this->m_values.resize(n);
}
return true;
}
//----------------------------------------------------------------------------
......@@ -55,7 +71,7 @@ Component::Type AttributeReferenceComponent::type() const
bool AttributeReferenceComponent::setValue(int element, slctk::AttributePtr att)
{
const AttributeReferenceComponentDefinition *def =
static_cast<const AttributeReferenceComponentDefinition *>(this->definition());
static_cast<const AttributeReferenceComponentDefinition *>(this->definition().get());
if (def->isValueValid(att))
{
this->m_values[element] = att;
......@@ -64,11 +80,6 @@ bool AttributeReferenceComponent::setValue(int element, slctk::AttributePtr att)
return false;
}
//----------------------------------------------------------------------------
void AttributeReferenceComponent::updateDiscreteValue(int)
{
std::cerr << "AttributeReferenceComponent::updateDiscreteValue - Not Implemented!\n";
}
//----------------------------------------------------------------------------
const std::string &
AttributeReferenceComponent::valueAsString(int element,
const std::string &format) const
......@@ -85,7 +96,7 @@ AttributeReferenceComponent::appendValue(slctk::AttributePtr val)
{
//First - are we allowed to change the number of values?
const AttributeReferenceComponentDefinition *def =
static_cast<const AttributeReferenceComponentDefinition *>(this->definition());
static_cast<const AttributeReferenceComponentDefinition *>(this->definition().get());
int n = def->numberOfValues();
if (n)
{
......@@ -105,40 +116,26 @@ AttributeReferenceComponent::removeValue(int element)
{
//First - are we allowed to change the number of values?
const AttributeReferenceComponentDefinition *def =
static_cast<const AttributeReferenceComponentDefinition *>(this->definition());
static_cast<const AttributeReferenceComponentDefinition *>(this->definition().get());
int n = def->numberOfValues();
if (n)
{
return false; // The number of values is fixed
}
this->m_values.erase(this->m_values.begin()+element);
this->m_isSet.erase(this->m_isSet.begin()+element);
if (def->isDiscrete())
{
this->m_discreteIndices.erase(this->m_discreteIndices.begin()+element);
}
return true;
}
//----------------------------------------------------------------------------
bool
AttributeReferenceComponent::setToDefault(int)
{
std::cerr << "AttributeReferenceComponent::setToDefault - Not Implemented!\n";
return false;
}
//----------------------------------------------------------------------------
void
AttributeReferenceComponent::reset()
{
const AttributeReferenceComponentDefinition *def
= static_cast<const AttributeReferenceComponentDefinition *>(this->definition());
= static_cast<const AttributeReferenceComponentDefinition *>(this->definition().get());
// Was the initial size 0?
int i, n = def->numberOfValues();
if (!n)
{
this->m_values.clear();
this->m_isSet.clear();
this->m_discreteIndices.clear();
return;
}
for (i = 0; i < n; i++)
......
......@@ -29,7 +29,7 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include "AttributeExports.h"
#include "attribute/PublicPointerDefs.h"
#include "attribute/ValueComponent.h"
#include "attribute/Component.h"
#include <vector>
namespace slctk
......@@ -38,12 +38,13 @@ namespace slctk
{
class Attribute;
class AttributeReferenceComponentDefinition;
class SLCTKATTRIBUTE_EXPORT AttributeReferenceComponent : public ValueComponent
class SLCTKATTRIBUTE_EXPORT AttributeReferenceComponent : public Component
{
public:
AttributeReferenceComponent(const AttributeReferenceComponentDefinition *def);
AttributeReferenceComponent();
virtual ~AttributeReferenceComponent();
virtual Component::Type type() const;
virtual bool setDefinition(slctk::ConstAttributeComponentDefinitionPtr def);
slctk::AttributePtr value() const
{return this->m_values[0].lock();}
slctk::AttributePtr value(int element) const
......@@ -54,10 +55,9 @@ namespace slctk
bool appendValue(slctk::AttributePtr val);
bool removeValue(int element);
virtual void reset();
virtual bool setToDefault(int element);
virtual const std::string &valueAsString(int element, const std::string &format) const;
virtual bool isSet() const
{ return this->m_isSet[0];}
{ return this->m_values[0].lock() != NULL;}
virtual bool isSet(int element) const
{return this->m_values[element].lock() != NULL;}
virtual void unset()
......@@ -66,8 +66,8 @@ namespace slctk
{this->m_values[element].reset();}
protected:
virtual void updateDiscreteValue(int element);
std::vector<WeakAttributePtr>m_values;
mutable std::string m_tempString;
private:
};
};
......
......@@ -32,8 +32,10 @@ using namespace slctk::attribute;
AttributeReferenceComponentDefinition::
AttributeReferenceComponentDefinition(const std::string &myName,
unsigned long myId):
ValueComponentDefinition(myName, myId), m_definition()
ComponentDefinition(myName, myId), m_definition()
{
this->m_useCommonLabel = false;
this->m_numberOfValues = 0;
}
//----------------------------------------------------------------------------
......@@ -41,11 +43,6 @@ AttributeReferenceComponentDefinition::~AttributeReferenceComponentDefinition()
{
}
//----------------------------------------------------------------------------
bool AttributeReferenceComponentDefinition::hasRange() const
{
return false;
}
//----------------------------------------------------------------------------
bool
AttributeReferenceComponentDefinition::isValueValid(slctk::AttributePtr att) const
{
......@@ -62,6 +59,57 @@ AttributeReferenceComponentDefinition::isValueValid(slctk::AttributePtr att) con
//----------------------------------------------------------------------------
slctk::AttributeComponentPtr AttributeReferenceComponentDefinition::buildComponent() const
{
return slctk::AttributeComponentPtr(new AttributeReferenceComponent(this));
return slctk::AttributeComponentPtr(new AttributeReferenceComponent());
}
//----------------------------------------------------------------------------
void AttributeReferenceComponentDefinition::setNumberOfValues(int esize)
{
if (esize == this->m_numberOfValues)
{
return;
}
this->m_numberOfValues = esize;
if (!this->m_useCommonLabel)
{
this->m_valueLables.resize(esize);
}
}
//----------------------------------------------------------------------------
void AttributeReferenceComponentDefinition::setValueLabel(int element, const std::string &elabel)
{
if (this->m_numberOfValues == 0)
{
return;
}
if (this->m_valueLables.size() != this->m_numberOfValues)
{
this->m_valueLables.resize(this->m_numberOfValues);
}
this->m_useCommonLabel = false;
this->m_valueLables[element] = elabel;
}
//----------------------------------------------------------------------------
void AttributeReferenceComponentDefinition::setCommonValueLable(const std::string &elable)
{
if (this->m_valueLables.size() != 1)
{
this->m_valueLables.resize(1);
}
this->m_useCommonLabel = true;
this->m_valueLables[0] = elable;
}
//----------------------------------------------------------------------------
std::string AttributeReferenceComponentDefinition::valueLable(int element) const
{
if (this->m_useCommonLabel)
{
return this->m_valueLables[0];
}
if (this->m_valueLables.size())
{
return this->m_valueLables[element];
}
return ""; // If we threw execeptions this method could return const string &
}
//----------------------------------------------------------------------------
......@@ -30,7 +30,7 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include "AttributeExports.h"
#include "attribute/PublicPointerDefs.h"
#include "ValueComponentDefinition.h"
#include "ComponentDefinition.h"
namespace slctk
{
......@@ -39,15 +39,13 @@ namespace slctk
class Attribute;
class Definition;
class SLCTKATTRIBUTE_EXPORT AttributeReferenceComponentDefinition:
public ValueComponentDefinition
public ComponentDefinition
{
public:
AttributeReferenceComponentDefinition(const std::string &myName,
unsigned long myId);
virtual ~AttributeReferenceComponentDefinition();
virtual bool hasRange() const;
slctk::AttributeDefinitionPtr attributeDefinition() const
{return this->m_definition.lock();}
......@@ -57,9 +55,22 @@ namespace slctk
bool isValueValid(slctk::AttributePtr att) const;
virtual slctk::AttributeComponentPtr buildComponent() const;
int numberOfValues() const
{return this->m_numberOfValues;}
void setNumberOfValues(int esize);
bool hasValueLables() const
{return this->m_valueLables.size();}
void setValueLabel(int element, const std::string &elabel);
void setCommonValueLable(const std::string &elable);
std::string valueLable(int element) const;
protected:
slctk::WeakAttributeDefinitionPtr m_definition;
private:
bool m_useCommonLabel;
std::vector<std::string> m_valueLables;
int m_numberOfValues;
private:
};
};
......
......@@ -24,25 +24,41 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include "attribute/Component.h"
#include "attribute/ComponentDefinition.h"
#include <iostream>
using namespace slctk::attribute;
//----------------------------------------------------------------------------
Component::Component(const ComponentDefinition *def):
m_isEnabled(true), m_definition(def)
Component::Component():
m_isEnabled(true), m_definition()
{
}
//----------------------------------------------------------------------------
Component::~Component()
{
std::cout << "Component " << this->name() << " deleted\n";
}
//----------------------------------------------------------------------------
const std::string &Component::name() const
{
if (this->m_definition == NULL)
{
this->m_tempString = "";
return this->m_tempString;
}
return this->m_definition->name();
}
//----------------------------------------------------------------------------
bool Component::setDefinition(slctk::ConstAttributeComponentDefinitionPtr def)
{
if (this->m_definition != NULL)
{
return false;
}
this->m_definition = def;
return true;
}
//----------------------------------------------------------------------------
bool Component::isOptional() const
{
return this->m_definition->isOptional();
......
......@@ -52,11 +52,12 @@ namespace slctk
NUMBER_OF_TYPES
};
Component(const slctk::attribute::ComponentDefinition *def);
Component();
virtual ~Component();
const std::string &name() const;
virtual Component::Type type() const = 0;
const slctk::attribute::ComponentDefinition *definition() const
virtual bool setDefinition(slctk::ConstAttributeComponentDefinitionPtr def);
slctk::ConstAttributeComponentDefinitionPtr definition() const
{return this->m_definition;}
bool isOptional() const;
......@@ -78,7 +79,8 @@ namespace slctk
// This method allows any Component to delete another - USE WITH CARE!
void deleteComponent();
bool m_isEnabled;
const ComponentDefinition *m_definition;
mutable std::string m_tempString;
slctk::ConstAttributeComponentDefinitionPtr m_definition;
private:
};
......
......@@ -23,6 +23,7 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include "attribute/ComponentDefinition.h"
#include <iostream>
using namespace slctk::attribute;
//----------------------------------------------------------------------------
......@@ -39,6 +40,7 @@ ComponentDefinition::ComponentDefinition(const std::string &myName,
//----------------------------------------------------------------------------
ComponentDefinition::~ComponentDefinition()
{
std::cout << "Component Definition " << m_name << " deleted\n";
}
//----------------------------------------------------------------------------
bool ComponentDefinition::isMemberOf(const std::vector<std::string> &catagories) const
......
......@@ -26,6 +26,7 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include "attribute/Attribute.h"
#include "attribute/Cluster.h"
#include "attribute/Component.h"
#include "attribute/ComponentDefinition.h"
#include <iostream>
......@@ -49,12 +50,6 @@ Definition::Definition(const std::string &myType, slctk::AttributeClusterPtr myC
Definition::~Definition()
{
std::cout << "Deleting Definition " << this->m_type << std::endl;
std::size_t i, n = this->m_componentDefs.size();
for (i = 0; i < n; i++)
{
delete this->m_componentDefs[i];
}
}
//----------------------------------------------------------------------------
slctk::AttributeDefinitionPtr Definition::baseDefinition() const
......@@ -155,6 +150,7 @@ void Definition::buildAttribute(AttributePtr att) const
for (i = 0; i < n; i++)
{
comp = this->m_componentDefs[i]->buildComponent();
comp->setDefinition(this->m_componentDefs[i]);
att->addComponent(comp);
}
}
......@@ -170,7 +166,7 @@ bool Definition::isMemberOf(const std::vector<std::string> &catagories) const
return false;
}
//----------------------------------------------------------------------------
bool Definition::addComponentDefinition(ComponentDefinition *cdef)
bool Definition::addComponentDefinition(slctk::AttributeComponentDefinitionPtr cdef)
{
// First see if there is a component by the same name
if (this->findComponentPosition(cdef->name()) >= 0)
......
......@@ -136,12 +136,13 @@ namespace slctk
bool conflicts(slctk::AttributeDefinitionPtr definition) const;
std::size_t numberOfComponentDefinitions() const
{return this->m_componentDefs.size();}
slctk::attribute::ComponentDefinition *componentDefinition(int ith) const
slctk::AttributeComponentDefinitionPtr componentDefinition(int ith) const
{
return (ith < 0) ? NULL : (ith >= this->m_componentDefs.size() ?
NULL : this->m_componentDefs[ith]);
return (ith < 0) ? slctk::AttributeComponentDefinitionPtr()
: (ith >= this->m_componentDefs.size() ?
slctk::AttributeComponentDefinitionPtr() : this->m_componentDefs[ith]);
}
bool addComponentDefinition(slctk::attribute::ComponentDefinition *cdef);
bool addComponentDefinition(slctk::AttributeComponentDefinitionPtr cdef);
int findComponentPosition(const std::string &name) const;
......@@ -168,7 +169,7 @@ namespace slctk
bool m_isNodal;
std::set<std::string> m_catagories;
int m_advanceLevel;
std::vector<slctk::attribute::ComponentDefinition *> m_componentDefs;
std::vector<slctk::AttributeComponentDefinitionPtr> m_componentDefs;
std::map<std::string, int> m_componentDefPositions;
//Is Unique indicates if more than one attribute of this type can be assigned to a
// model entity - NOTE This can be inherited meaning that if the definition's Super definition
......
......@@ -28,8 +28,7 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
using namespace slctk::attribute;
//----------------------------------------------------------------------------
DoubleComponent::DoubleComponent(const DoubleComponentDefinition *def):
ValueComponentTemplate<double>(def)
DoubleComponent::DoubleComponent()
{
}
......
......@@ -41,7 +41,7 @@ namespace slctk
{
friend class DoubleComponentDefinition;
public:
DoubleComponent(const DoubleComponentDefinition *def);
DoubleComponent();
virtual ~DoubleComponent();
virtual Component::Type type() const;
protected:
......
......@@ -40,5 +40,5 @@ DoubleComponentDefinition::~DoubleComponentDefinition()
//----------------------------------------------------------------------------
slctk::AttributeComponentPtr DoubleComponentDefinition::buildComponent() const
{
return slctk::AttributeComponentPtr(new DoubleComponent(this));
return slctk::AttributeComponentPtr(new DoubleComponent());
}
......@@ -27,18 +27,8 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
using namespace slctk::attribute;
//----------------------------------------------------------------------------
GroupComponent::GroupComponent(const GroupComponentDefinition *def):
Component(def)
GroupComponent::GroupComponent()
{
std::size_t i, n = def->numberOfGroups();
if (n)
{
this->m_components.resize(n);
for (i = 0; i < n; i++)
{
def->buildGroup(this->m_components[i]);
}
}
}
//----------------------------------------------------------------------------
......@@ -51,17 +41,43 @@ Component::Type GroupComponent::type() const
return GROUP;
}
//----------------------------------------------------------------------------
bool
GroupComponent::setDefinition(slctk::ConstAttributeComponentDefinitionPtr gdef)
{
// Note that we do a dynamic cast here since we don't
// know if the proper definition is being passed
const GroupComponentDefinition *def =
dynamic_cast<const GroupComponentDefinition *>(gdef.get());
// Call the parent's set definition - similar to constructor calls
// we call from base to derived
if ((def == NULL) || (Component::setDefinition(gdef)))
{
return false;
}
this->m_definition = gdef;
std::size_t i, n = def->numberOfGroups();
if (n)
{
this->m_components.resize(n);
for (i = 0; i < n; i++)
{
def->buildGroup(this->m_components[i]);
}
}
return true;
}
//----------------------------------------------------------------------------
std::size_t GroupComponent::numberOfComponentsPerGroup() const
{
const GroupComponentDefinition *def =
static_cast<const GroupComponentDefinition *>(this->definition());
static_cast<const GroupComponentDefinition *>(this->definition().get());
return def->numberOfComponentDefinitions();
}
//----------------------------------------------------------------------------
bool GroupComponent::appendGroup()
{
const GroupComponentDefinition *def =
static_cast<const GroupComponentDefinition *>(this->definition());
static_cast<const GroupComponentDefinition *>(this->definition().get());
std::size_t n = def->numberOfGroups();
if (n)
{
......@@ -77,7 +93,7 @@ bool GroupComponent::appendGroup()
bool GroupComponent::removeGroup(int element)
{
const GroupComponentDefinition *def =
static_cast<const GroupComponentDefinition *>(this->definition());
static_cast<const GroupComponentDefinition *>(this->definition().get());
std::size_t n = def->numberOfGroups();
if (n)
{
......@@ -91,7 +107,7 @@ bool GroupComponent::removeGroup(int element)
slctk::AttributeComponentPtr GroupComponent::find(int element, const std::string &name)
{
const GroupComponentDefinition *def =
static_cast<const GroupComponentDefinition *>(this->definition());
static_cast<const GroupComponentDefinition *>(this->definition().get());
int i = def->findComponentPosition(name);
return (i < 0) ? slctk::AttributeComponentPtr() : this->m_components[element][i];
}
......@@ -99,7 +115,7 @@ slctk::AttributeComponentPtr GroupComponent::find(int element, const std::string
slctk::ConstAttributeComponentPtr GroupComponent::find(int element, const std::string &name) const
{
const GroupComponentDefinition *def =
static_cast<const GroupComponentDefinition *>(this->definition());
static_cast<const GroupComponentDefinition *>(this->definition().get());
int i = def->findComponentPosition(name);
if (i < 0)
{
......
......@@ -38,9 +38,10 @@ namespace slctk
class SLCTKATTRIBUTE_EXPORT GroupComponent : public Component
{
public:
GroupComponent(const GroupComponentDefinition *def);
GroupComponent();
virtual ~GroupComponent();
virtual Component::Type type() const;
virtual bool setDefinition(slctk::ConstAttributeComponentDefinitionPtr def);
std::size_t numberOfComponentsPerGroup() const;
std::size_t numberOfGroups() const
{return this->m_components.size();}
......
......@@ -36,19 +36,15 @@ GroupComponentDefinition::GroupComponentDefinition(const std::string &myName,
//----------------------------------------------------------------------------
GroupComponentDefinition::~GroupComponentDefinition()
{
std::size_t i, n = this->m_componentDefs.size();
for (i = 0; i < n; i++)
{
delete this->m_componentDefs[i];
}
}
//----------------------------------------------------------------------------
slctk::AttributeComponentPtr GroupComponentDefinition::buildComponent() const
{
return slctk::AttributeComponentPtr(new GroupComponent(this));
return slctk::AttributeComponentPtr(new GroupComponent());
}
//----------------------------------------------------------------------------
bool GroupComponentDefinition::addComponentDefinition(ComponentDefinition *cdef)
bool GroupComponentDefinition::
addComponentDefinition(slctk::AttributeComponentDefinitionPtr cdef)
{
// First see if there is a component by the same name
if (this->findComponentPosition(cdef->name()) >= 0)
......@@ -61,13 +57,15 @@ bool GroupComponentDefinition::addComponentDefinition(ComponentDefinition *cdef)
return true;
}
//----------------------------------------------------------------------------
void GroupComponentDefinition::buildGroup(std::vector<slctk::AttributeComponentPtr> &group) const
void GroupComponentDefinition::
buildGroup(std::vector<slctk::AttributeComponentPtr> &group) const
{
std::size_t i, n = this->m_componentDefs.size();
group.resize(n);
for (i = 0; i < n; i++)
{
group[i] = this->m_componentDefs[i]->buildComponent();
group[i]->setDefinition(this->m_componentDefs[i]);
}
}
//----------------------------------------------------------------------------
......@@ -45,12 +45,13 @@ namespace slctk
virtual ~GroupComponentDefinition();
std::size_t numberOfComponentDefinitions() const
{return this->m_componentDefs.size();}
slctk::attribute::ComponentDefinition *componentDefinition(int ith) const
slctk::AttributeComponentDefinitionPtr componentDefinition(int ith) const
{
return (ith < 0) ? NULL : (ith >= this->m_componentDefs.size() ?
NULL : this->m_componentDefs[ith]);
return (ith < 0) ? slctk::AttributeComponentDefinitionPtr() :
(ith >= this->m_componentDefs.size() ?
slctk::AttributeComponentDefinitionPtr() : this->m_componentDefs[ith]);
}
bool addComponentDefinition(ComponentDefinition *cdef);
bool addComponentDefinition(slctk::AttributeComponentDefinitionPtr cdef);
int findComponentPosition(const std::string &name) const;
int numberOfGroups() const
......@@ -61,7 +62,7 @@ namespace slctk
void buildGroup(std::vector<slctk::AttributeComponentPtr> &group) const;
protected:
std::vector<slctk::attribute::ComponentDefinition *> m_componentDefs;
std::vector<slctk::AttributeComponentDefinitionPtr> m_componentDefs;
std::map<std::string, int> m_componentDefPositions;
int m_numberOfGroups;
private:
......
......@@ -28,8 +28,7 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
using namespace slctk::attribute;
//----------------------------------------------------------------------------
IntegerComponent::IntegerComponent(const IntegerComponentDefinition *def):
ValueComponentTemplate<int>(def)
IntegerComponent::IntegerComponent()
{
}
......
......@@ -41,7 +41,7 @@ namespace slctk
{
friend class IntegerComponentDefinition;
public:
IntegerComponent(const IntegerComponentDefinition *def);
IntegerComponent();
virtual ~IntegerComponent();
virtual Component::Type type() const;
protected:
......
......@@ -40,5 +40,5 @@ IntegerComponentDefinition::~IntegerComponentDefinition()
//----------------------------------------------------------------------------
slctk::AttributeComponentPtr IntegerComponentDefinition::buildComponent() const
{
return slctk::AttributeComponentPtr(new IntegerComponent(this));
return slctk::AttributeComponentPtr(new IntegerComponent());
}
......@@ -117,6 +117,7 @@ slctk::AttributePtr Manager::createAttribute(const std::string &name,
return slctk::AttributePtr();
}
a = slctk::AttributePtr(new Attribute(name, c, id));
c->definition()->buildAttribute(a);
c->addAttribute(a);
this->m_attributes[name] = a;
this->m_attributeIdMap[id] = a;
......
......@@ -33,6 +33,11 @@ namespace slctk
{
template <typename T> struct sharedPtr : public std::tr1::shared_ptr<T> {};
template <typename T> struct weakPtr : public std::tr1::weak_ptr<T>{};
template <typename T, typename U>
inline std::tr1::shared_ptr<T> dynamicCastPointer(const std::tr1::shared_ptr<U> &r)
{
return std::tr1::dynamic_pointer_cast<T>(r);
}
namespace attribute
{
......@@ -69,6 +74,15 @@ namespace slctk
typedef std::tr1::shared_ptr<attribute::Component> AttributeComponentPtr;
typedef std::tr1::shared_ptr<const attribute::Component> ConstAttributeComponentPtr;
typedef std::tr1::shared_ptr<attribute::ComponentDefinition> AttributeComponentDefinitionPtr;
typedef std::tr1::shared_ptr<const attribute::ComponentDefinition> ConstAttributeComponentDefinitionPtr;
typedef std::tr1::shared_ptr<attribute::ValueComponent> ValueComponentPtr;
typedef std::tr1::shared_ptr<attribute::DoubleComponent> DoubleComponentPtr;
typedef std::tr1::shared_ptr<attribute::DoubleComponentDefinition> DoubleComponentDefinitionPtr;
typedef std::tr1::shared_ptr<attribute::IntegerComponent> IntegerComponentPtr;
typedef std::tr1