Commit 17e4c7f6 authored by Haocheng LIU's avatar Haocheng LIU

REFACTORING: Rename Item Type enums

DOUBLE, INT, etc are reserved keywords on Windows. DataBrowser, which
is an application using SMTK as a library would fail to build on
Windows due to this issue. This MR appends an `Type` to them and
rewrites them in camel case.
parent 8b096735
Pipeline #83409 passed with stage
This diff is collapsed.
......@@ -31,30 +31,30 @@ std::shared_ptr<HandlerItemDef> HandlerItemDef::create(const int type)
using namespace smtk::attribute;
switch (type)
{
case Item::DOUBLE:
case Item::DoubleType:
return std::make_shared<HandlerDouble>();
case Item::GROUP:
case Item::GroupType:
return std::make_shared<HandlerGroup>();
case Item::INT:
case Item::IntType:
return std::make_shared<HandlerInt>();
case Item::STRING:
case Item::StringType:
return std::make_shared<HandlerString>();
case Item::COLOR:
case Item::VOID:
case Item::ColorType:
case Item::VoidType:
return std::make_shared<HandlerVoid>();
case Item::FILE:
case Item::FileType:
return std::make_shared<HandlerFile>();
case Item::DIRECTORY:
case Item::DirectoryType:
return std::make_shared<HandlerDirectory>();
case Item::MODEL_ENTITY:
case Item::ModelEntityType:
return std::make_shared<HandlerModelEntity>();
case Item::MESH_SELECTION:
case Item::MeshSelectionType:
return std::make_shared<HandlerMeshSelection>();
case Item::MESH_ENTITY:
case Item::MeshEntityType:
return std::make_shared<HandlerMeshEntity>();
case Item::DATE_TIME:
case Item::DateTimeType:
return std::make_shared<HandlerDateTime>();
case Item::ATTRIBUTE_REF:
case Item::AttributeRefType:
return std::make_shared<HandlerRef>();
default:
std::cerr << "Error: Unknown type!\n";
......
......@@ -50,7 +50,7 @@ void ItemDefDataModel::appendBranchToRoot(smtk::attribute::DefinitionPtr def)
item->setData(2, Qt::DisplayRole, attDefType);
item->setReferencedData(itemDef);
if (itemDef->type() == smtk::attribute::Item::GROUP)
if (itemDef->type() == smtk::attribute::Item::GroupType)
{
this->appendRecursively(itemDef, item, attDefType);
}
......@@ -73,7 +73,7 @@ void ItemDefDataModel::appendRecursively(smtk::attribute::ItemDefinitionPtr pare
item->setData(2, Qt::DisplayRole, attDefType);
item->setReferencedData(itemDef);
if (itemDef->type() == smtk::attribute::Item::GROUP)
if (itemDef->type() == smtk::attribute::Item::GroupType)
{
this->appendRecursively(itemDef, item, attDefType);
}
......@@ -88,7 +88,7 @@ void ItemDefDataModel::insert(const Container& props)
const auto itemDef = props.ItemDefinition;
const auto parentElement = static_cast<ItemDefElement*>(this->getItem(props.ParentIndex));
const auto& parentItemDef = parentElement->getReferencedDataConst();
if (parentItemDef && parentItemDef->type() == smtk::attribute::Item::GROUP)
if (parentItemDef && parentItemDef->type() == smtk::attribute::Item::GroupType)
{
auto group = std::static_pointer_cast<smtk::attribute::GroupItemDefinition>(parentItemDef);
group->addItemDefinition(itemDef);
......@@ -128,7 +128,7 @@ void ItemDefDataModel::remove(const QModelIndex& itemIndex, smtk::attribute::Def
const auto& parentItemDef = parentElem->getReferencedDataConst();
const auto item = static_cast<ItemDefElement*>(this->getItem(itemIndex));
auto itemDef = item->getReferencedDataConst();
if (parentItemDef && parentItemDef->type() == smtk::attribute::Item::GROUP)
if (parentItemDef && parentItemDef->type() == smtk::attribute::Item::GroupType)
{
auto group = std::static_pointer_cast<smtk::attribute::GroupItemDefinition>(parentItemDef);
group->removeItemDefinition(itemDef);
......
......@@ -61,7 +61,7 @@ void ItemDefDialog::setItemDef(smtk::attribute::ItemDefinitionPtr def)
void ItemDefDialog::setValidationInstances(
smtk::attribute::ItemDefinitionPtr itemDef, smtk::attribute::DefinitionPtr def)
{
if (itemDef && itemDef->type() == smtk::attribute::Item::GROUP)
if (itemDef && itemDef->type() == smtk::attribute::Item::GroupType)
{
this->ParentGroup = std::static_pointer_cast<smtk::attribute::GroupItemDefinition>(itemDef);
}
......
......@@ -31,7 +31,7 @@ ComponentItem::~ComponentItem()
Item::Type ComponentItem::type() const
{
return COMPONENT;
return ComponentType;
}
bool ComponentItem::isValid() const
......
......@@ -40,7 +40,7 @@ ComponentItemDefinition::~ComponentItemDefinition()
/// Return the type of storage used by items defined by this class.
Item::Type ComponentItemDefinition::type() const
{
return Item::COMPONENT;
return Item::ComponentType;
}
bool ComponentItemDefinition::acceptsResourceComponents(const std::string& uniqueName) const
......
......@@ -33,7 +33,7 @@ DateTimeItem::~DateTimeItem()
Item::Type DateTimeItem::type() const
{
return Item::DATE_TIME;
return Item::DateTimeType;
}
bool DateTimeItem::isValid() const
......
......@@ -29,7 +29,7 @@ DateTimeItemDefinition::~DateTimeItemDefinition()
Item::Type DateTimeItemDefinition::type() const
{
return Item::DATE_TIME;
return Item::DateTimeType;
}
bool DateTimeItemDefinition::setDefaultValue(const sc::DateTimeZonePair& value)
......
......@@ -32,5 +32,5 @@ DirectoryItem::~DirectoryItem()
Item::Type DirectoryItem::type() const
{
return DIRECTORY;
return DirectoryType;
}
......@@ -24,7 +24,7 @@ DirectoryItemDefinition::~DirectoryItemDefinition()
}
Item::Type DirectoryItemDefinition::type() const
{
return Item::DIRECTORY;
return Item::DirectoryType;
}
smtk::attribute::ItemPtr DirectoryItemDefinition::buildItem(
......
......@@ -29,7 +29,7 @@ DoubleItem::~DoubleItem()
Item::Type DoubleItem::type() const
{
return DOUBLE;
return DoubleType;
}
bool DoubleItem::assign(ConstItemPtr& sourceItem, unsigned int options)
......
......@@ -23,7 +23,7 @@ DoubleItemDefinition::~DoubleItemDefinition()
Item::Type DoubleItemDefinition::type() const
{
return Item::DOUBLE;
return Item::DoubleType;
}
smtk::attribute::ItemPtr DoubleItemDefinition::buildItem(
......
......@@ -45,7 +45,7 @@ FileItem::~FileItem()
Item::Type FileItem::type() const
{
return FILE;
return FileType;
}
void FileItem::addRecentValue(const std::string& val)
......
......@@ -48,7 +48,7 @@ FileItemDefinition::~FileItemDefinition()
Item::Type FileItemDefinition::type() const
{
return Item::FILE;
return Item::FileType;
}
int FileItemDefinition::filterId(const std::string& val) const
......
......@@ -36,7 +36,7 @@ FileSystemItemDefinition::~FileSystemItemDefinition()
Item::Type FileSystemItemDefinition::type() const
{
return Item::DIRECTORY;
return Item::DirectoryType;
}
bool FileSystemItemDefinition::isValueValid(const std::string& val) const
......
......@@ -49,7 +49,7 @@ void GroupItem::detachAllItems()
Item::Type GroupItem::type() const
{
return GROUP;
return GroupType;
}
bool GroupItem::isValid() const
......
......@@ -32,7 +32,7 @@ GroupItemDefinition::~GroupItemDefinition()
Item::Type GroupItemDefinition::type() const
{
return Item::GROUP;
return Item::GroupType;
}
smtk::attribute::ItemPtr GroupItemDefinition::buildItem(
......
......@@ -29,7 +29,7 @@ IntItem::~IntItem()
Item::Type IntItem::type() const
{
return INT;
return IntType;
}
bool IntItem::assign(ConstItemPtr& sourceItem, unsigned int options)
......
......@@ -23,7 +23,7 @@ IntItemDefinition::~IntItemDefinition()
Item::Type IntItemDefinition::type() const
{
return Item::INT;
return Item::IntType;
}
smtk::attribute::ItemPtr IntItemDefinition::buildItem(
......
......@@ -197,31 +197,31 @@ std::string Item::type2String(Item::Type t)
{
switch (t)
{
case ATTRIBUTE_REF:
case AttributeRefType:
return "AttributeRef";
case COLOR:
case ColorType:
return "Color";
case DIRECTORY:
case DirectoryType:
return "Directory";
case DOUBLE:
case DoubleType:
return "Double";
case FILE:
case FileType:
return "File";
case GROUP:
case GroupType:
return "Group";
case INT:
case IntType:
return "Int";
case STRING:
case StringType:
return "String";
case VOID:
case VoidType:
return "Void";
case MODEL_ENTITY:
case ModelEntityType:
return "ModelEntity";
case MESH_SELECTION:
case MeshSelectionType:
return "MeshSelection";
case MESH_ENTITY:
case MeshEntityType:
return "MeshEntity";
case DATE_TIME:
case DateTimeType:
return "DateTime";
default:
return "";
......@@ -233,55 +233,55 @@ Item::Type Item::string2Type(const std::string& s)
{
if (s == "AttributeRef")
{
return ATTRIBUTE_REF;
return AttributeRefType;
}
if (s == "Color")
{
return COLOR;
return ColorType;
}
if (s == "Directory")
{
return DIRECTORY;
return DirectoryType;
}
if (s == "Double")
{
return DOUBLE;
return DoubleType;
}
if (s == "File")
{
return FILE;
return FileType;
}
if (s == "Group")
{
return GROUP;
return GroupType;
}
if (s == "Int")
{
return INT;
return IntType;
}
if (s == "String")
{
return STRING;
return StringType;
}
if (s == "Void")
{
return VOID;
return VoidType;
}
if (s == "ModelEntity")
{
return MODEL_ENTITY;
return ModelEntityType;
}
if (s == "MeshSelection")
{
return MESH_SELECTION;
return MeshSelectionType;
}
if (s == "MeshEntity")
{
return MESH_ENTITY;
return MeshEntityType;
}
if (s == "DateTime")
{
return DATE_TIME;
return DateTimeType;
}
return NUMBER_OF_TYPES;
}
......@@ -42,21 +42,21 @@ public:
smtkTypeMacroBase(Item);
enum Type
{
ATTRIBUTE_REF,
DOUBLE,
GROUP,
INT,
STRING,
VOID,
FILE,
DIRECTORY,
COLOR,
MODEL_ENTITY,
MESH_SELECTION,
MESH_ENTITY,
DATE_TIME,
COMPONENT,
RESOURCE,
AttributeRefType,
DoubleType,
GroupType,
IntType,
StringType,
VoidType,
FileType,
DirectoryType,
ColorType,
ModelEntityType,
MeshSelectionType,
MeshEntityType,
DateTimeType,
ComponentType,
ResourceType,
NUMBER_OF_TYPES
};
......
......@@ -65,7 +65,7 @@ Item::Type MeshItem::type() const
{
return def->type();
}
return Item::MESH_ENTITY;
return Item::MeshEntityType;
}
std::size_t MeshItem::numberOfValues() const
......
......@@ -28,7 +28,7 @@ MeshItemDefinition::~MeshItemDefinition()
Item::Type MeshItemDefinition::type() const
{
return Item::MESH_ENTITY;
return Item::MeshEntityType;
}
/// Return the number of values (mesh entities) required by this definition.
std::size_t MeshItemDefinition::numberOfRequiredValues() const
......
......@@ -59,7 +59,7 @@ Item::Type MeshSelectionItem::type() const
{
return def->type();
}
return Item::MESH_SELECTION;
return Item::MeshEntityType;
}
bool MeshSelectionItem::isValid() const
......
......@@ -26,7 +26,7 @@ MeshSelectionItemDefinition::~MeshSelectionItemDefinition()
Item::Type MeshSelectionItemDefinition::type() const
{
return Item::MESH_SELECTION;
return Item::MeshSelectionType;
}
smtk::model::BitFlags MeshSelectionItemDefinition::membershipMask() const
......
......@@ -37,7 +37,7 @@ ModelEntityItem::~ModelEntityItem()
/// Return the type of storage used by the item.
Item::Type ModelEntityItem::type() const
{
return MODEL_ENTITY;
return ModelEntityType;
}
bool ModelEntityItem::isValid() const
......
......@@ -40,7 +40,7 @@ ModelEntityItemDefinition::~ModelEntityItemDefinition()
/// Return the type of storage used by items defined by this class.
Item::Type ModelEntityItemDefinition::type() const
{
return Item::MODEL_ENTITY;
return Item::ModelEntityType;
}
/// Return the mask used to accept or reject entities as attribute values.
......
......@@ -68,7 +68,7 @@ void RefItem::clearAllReferences()
Item::Type RefItem::type() const
{
return ATTRIBUTE_REF;
return AttributeRefType;
}
bool RefItem::isValid() const
......
......@@ -32,7 +32,7 @@ RefItemDefinition::~RefItemDefinition()
Item::Type RefItemDefinition::type() const
{
return Item::ATTRIBUTE_REF;
return Item::AttributeRefType;
}
bool RefItemDefinition::isValueValid(smtk::attribute::AttributePtr att) const
......
......@@ -29,7 +29,7 @@ StringItem::~StringItem()
Item::Type StringItem::type() const
{
return STRING;
return StringType;
}
bool StringItem::assign(ConstItemPtr& sourceItem, unsigned int options)
......
......@@ -25,7 +25,7 @@ StringItemDefinition::~StringItemDefinition()
Item::Type StringItemDefinition::type() const
{
return Item::STRING;
return Item::StringType;
}
smtk::attribute::ItemPtr StringItemDefinition::buildItem(
......
......@@ -46,7 +46,7 @@ VoidItem::~VoidItem()
Item::Type VoidItem::type() const
{
return VOID;
return VoidType;
}
bool VoidItem::isValid() const
......
......@@ -37,7 +37,7 @@ smtk::attribute::ItemPtr VoidItemDefinition::buildItem(
Item::Type VoidItemDefinition::type() const
{
return Item::VOID;
return Item::VoidType;
}
smtk::attribute::ItemDefinitionPtr smtk::attribute::VoidItemDefinition::createCopy(
......
......@@ -56,19 +56,19 @@ PySharedPtrClass< smtk::attribute::Item > pybind11_init_smtk_attribute_Item(py::
.def_static("string2Type", &smtk::attribute::Item::string2Type, py::arg("s"))
;
py::enum_<smtk::attribute::Item::Type>(instance, "Type")
.value("ATTRIBUTE_REF", smtk::attribute::Item::Type::ATTRIBUTE_REF)
.value("DOUBLE", smtk::attribute::Item::Type::DOUBLE)
.value("GROUP", smtk::attribute::Item::Type::GROUP)
.value("INT", smtk::attribute::Item::Type::INT)
.value("STRING", smtk::attribute::Item::Type::STRING)
.value("VOID", smtk::attribute::Item::Type::VOID)
.value("FILE", smtk::attribute::Item::Type::FILE)
.value("DIRECTORY", smtk::attribute::Item::Type::DIRECTORY)
.value("COLOR", smtk::attribute::Item::Type::COLOR)
.value("MODEL_ENTITY", smtk::attribute::Item::Type::MODEL_ENTITY)
.value("MESH_SELECTION", smtk::attribute::Item::Type::MESH_SELECTION)
.value("MESH_ENTITY", smtk::attribute::Item::Type::MESH_ENTITY)
.value("DATE_TIME", smtk::attribute::Item::Type::DATE_TIME)
.value("AttributeRefType", smtk::attribute::Item::Type::AttributeRefType)
.value("DoubleType", smtk::attribute::Item::Type::DoubleType)
.value("GroupType", smtk::attribute::Item::Type::GroupType)
.value("IntType", smtk::attribute::Item::Type::IntType)
.value("StringType", smtk::attribute::Item::Type::StringType)
.value("VoidType", smtk::attribute::Item::Type::VoidType)
.value("FileType", smtk::attribute::Item::Type::FileType)
.value("DirectoryType", smtk::attribute::Item::Type::DirectoryType)
.value("ColorType", smtk::attribute::Item::Type::ColorType)
.value("ModelEntityType", smtk::attribute::Item::Type::ModelEntityType)
.value("MeshSelectionType", smtk::attribute::Item::Type::MeshSelectionType)
.value("MeshEntityType", smtk::attribute::Item::Type::MeshEntityType)
.value("DateTimeType", smtk::attribute::Item::Type::DateTimeType)
.value("NUMBER_OF_TYPES", smtk::attribute::Item::Type::NUMBER_OF_TYPES)
.export_values();
py::enum_<smtk::attribute::Item::AssignmentOptions>(instance, "AssignmentOptions")
......
......@@ -28,31 +28,31 @@ func_list = \
(ValueItem, ValueItem._findChild, "findChild")]
type_dict = \
{Item.ATTRIBUTE_REF:
{Item.AttributeRefType:
(RefItem, RefItemDefinition),
Item.DOUBLE:
Item.DoubleType:
(DoubleItem, DoubleItemDefinition),
Item.GROUP:
Item.GroupType:
(GroupItem, GroupItemDefinition),
Item.INT:
Item.IntType:
(IntItem, IntItemDefinition),
Item.STRING:
Item.StringType:
(StringItem, StringItemDefinition),
Item.VOID:
Item.VoidType:
(VoidItem, VoidItemDefinition),
Item.FILE:
Item.FileType:
(FileItem, FileItemDefinition),
Item.DIRECTORY:
Item.DirectoryType:
(DirectoryItem, DirectoryItemDefinition),
Item.COLOR:
Item.ColorType:
(None, None),
Item.MODEL_ENTITY:
Item.ModelEntityType:
(ModelEntityItem, ModelEntityItemDefinition),
Item.MESH_ENTITY:
Item.MeshEntityType:
(MeshItem, MeshItemDefinition),
Item.MESH_SELECTION:
Item.MeshSelectionType:
(MeshSelectionItem, MeshSelectionItemDefinition),
Item.DATE_TIME:
Item.DateTimeType:
(DateTimeItem, DateTimeItemDefinition)
}
......
......@@ -136,11 +136,11 @@ int main()
{
switch (vcomp->type())
{
case AttComp::DOUBLE:
case AttComp::INT:
case AttComp::DoubleType:
case AttComp::IntType:
std::cout << " Value = " << vcomp->valueAsString() << std::endl;
break;
case AttComp::STRING:
case AttComp::StringType:
std::cout << " String Val = " << vcomp->valueAsString() << std::endl;
break;
default:
......
......@@ -175,11 +175,11 @@ int main()
{
switch (vitem->type())
{
case AttItem::DOUBLE:
case AttItem::INT:
case AttItem::DoubleType:
case AttItem::IntType:
std::cout << " Value = " << vitem->valueAsString() << std::endl;
break;
case AttItem::STRING:
case AttItem::StringType:
std::cout << " String Val = " << vitem->valueAsString() << std::endl;
break;
default:
......
......@@ -33,7 +33,7 @@ int unitComponentItem(int, char** const)
// Instantiate definition
auto compDef = ComponentItemDefinition::New("comp-def");
smtkTest(!!compDef, "Failed to instantiate ComponentItemDefinition");
smtkTest(compDef->type() == Item::COMPONENT, "Failed to return COMPONENT as definition type");
smtkTest(compDef->type() == Item::ComponentType, "Failed to return COMPONENT as definition type");
// Instantiate att collection, attdef, & attribute
CollectionPtr collection = Collection::create();
......@@ -43,11 +43,12 @@ int unitComponentItem(int, char** const)
ItemPtr item = att->find("comp-def");
smtkTest(!!item, "Failed to find Item");
smtkTest(item->type() == Item::COMPONENT, "Failed to return COMPONENT as item type");
smtkTest(item->type() == Item::ComponentType, "Failed to return COMPONENT as item type");
ComponentItemPtr compItem = att->findComponent("comp-def");
smtkTest(!!compItem, "Failed to find ComponentItem");
smtkTest(compItem->type() == Item::COMPONENT, "Failed to return COMPONENT as ComponentItem type");
smtkTest(
compItem->type() == Item::ComponentType, "Failed to return COMPONENT as ComponentItem type");
smtkTest(!compItem->isSet(), "isSet() failed to return false for default item");
return 0;
......
......@@ -38,7 +38,7 @@ void verifyDefault()
// Instantiate item definition
sa::DateTimeItemDefinitionPtr dtDef = sa::DateTimeItemDefinition::New("dt-def");
test(!!dtDef, "Failed to instantiate DateTimeItemDefinition");
test(dtDef->type() == sa::Item::DATE_TIME, "Failed to return DATE_TIME as definition type");
test(dtDef->type() == sa::Item::DateTimeType, "Failed to return DATE_TIME as definition type");
// Instantiate att collection, attdef, & attribute
sa::CollectionPtr sysptr = sa::Collection::create();
......@@ -49,11 +49,11 @@ void verifyDefault()
sa::ItemPtr item = att->find("dt-def");
test(!!item, "Failed to find Item");
test(item->type() == sa::Item::DATE_TIME, "Failed to return DATE_TIME as item type");
test(item->type() == sa::Item::DateTimeType, "Failed to return DATE_TIME as item type");
sa::DateTimeItemPtr dtItem = att->findDateTime("dt-def");
test(!!dtItem, "Failed to find DateTimeItem");
test(dtItem->type() == sa::Item::DATE_TIME, "Failed to return DATE_TIME as DateTimeItem type");
test(dtItem->type() == sa::Item::DateTimeType, "Failed to return DATE_TIME as DateTimeItem type");
test(!dtItem->isSet(), "isSet() failed to return false for default item");
// Set default value
......@@ -243,7 +243,7 @@ void verifySerialize()
test(discreteItemInput->numberOfActiveChildrenItems() == 1,
"Wrong number of active children; should be 1");
sa::ItemPtr activeChild = discreteItemInput->activeChildItem(0);
test(activeChild->type() == sa::Item::DATE_TIME, "Active child not DateTime");
test(activeChild->type() == sa::Item::DateTimeType, "Active child not DateTime");
}
} // end namespace
......
......@@ -134,16 +134,16 @@ if __name__ == '__main__':
comp.type())))
vcomp = smtk.attribute.ValueItem.CastTo(comp)
if vcomp:
if vcomp.type() == smtk.attribute.Item.DOUBLE:
if vcomp.type() == smtk.attribute.Item.DoubleType:
print(' Value = %s' % vcomp.valueAsString())
elif vcomp.type() == smtk.attribute.Item.INT:
elif vcomp.type() == smtk.attribute.Item.IntType:
print(' Value = %s' % vcomp.valueAsString())
elif vcomp.type() == smtk.attribute.Item.STRING:
elif vcomp.type() == smtk.attribute.Item.StringType:
print('String Val = %s' % vcomp.valueAsString())
else:
ecomp = smtk.attribute.ModelEntityItem.CastTo(comp)