28 UtScriptMethodArgs aVarArgs,
30 UtScriptClass* aReturnClassPtr,
31 UtScriptClass::InterfaceMethod* aInterfaceMethodPtr)
33 static_assert(std::is_base_of<WsfAuxDataEnabled, OBJECT_TYPE>::value,
34 "Template type of GetAuxData must derive from WsfAuxDataEnabled");
36 if (!aObjectPtr->HasAuxData())
42 UtAttributeBase* attribute = aObjectPtr->GetAuxDataConst().FindAttribute(aVarArgs[0].GetString());
44 if (attribute ==
nullptr)
51 auto attributeType = attribute->GetTypeId();
52 ut::script::Data::Type valueType =
UtScriptData(value).GetType();
53 if (attributeType == UtAttribute<bool>::GetClassTypeId())
55 if (valueType == ut::script::Data::Type::cBOOL)
57 attribute->Get(value);
62 attribute->Get(returnValueBool);
66 else if (attributeType == UtAttribute<int>::GetClassTypeId())
68 if (valueType == ut::script::Data::Type::cINT)
70 attribute->Get(value);
75 attribute->Get(returnValueInt);
79 else if (attributeType == UtAttribute<double>::GetClassTypeId())
81 if (valueType == ut::script::Data::Type::cDOUBLE)
83 attribute->Get(value);
87 double returnValueDouble;
88 attribute->Get(returnValueDouble);
92 else if (attributeType == UtAttribute<std::string>::GetClassTypeId())
94 if (valueType == ut::script::Data::Type::cSTRING)
96 attribute->Get(value);
100 std::string returnValueStr;
101 attribute->Get(returnValueStr);
107 attribute->Get(value);
114 UtScriptMethodArgs aVarArgs,
116 UtScriptClass* aReturnClassPtr,
117 UtScriptClass::InterfaceMethod* aInterfaceMethodPtr,
118 bool aSilentFailure =
false)
120 static_assert(std::is_base_of<WsfAuxDataEnabled, OBJECT_TYPE>::value,
121 "Template type of SetAuxData must derive from WsfAuxDataEnabled");
123 const std::string& attributeName = aVarArgs[0].GetString();
127 switch (value.GetType())
129 case ut::script::Data::Type::cBOOL:
130 aObjectPtr->GetAuxData().Assign(attributeName, value.GetBool());
132 case ut::script::Data::Type::cINT:
133 aObjectPtr->GetAuxData().Assign(attributeName, value.GetInt());
135 case ut::script::Data::Type::cDOUBLE:
136 aObjectPtr->GetAuxData().Assign(attributeName, value.GetDouble());
138 case ut::script::Data::Type::cSTRING:
139 aObjectPtr->GetAuxData().Assign(attributeName, value.GetString());
142 aObjectPtr->GetAuxData().Assign(attributeName, value);
150 UT_SCRIPT_ABORT(
"AuxData exists, but is not correct type.");
158 static_assert(std::is_base_of<WsfAuxDataEnabled, OBJECT_TYPE>::value,
159 "Template type of GetAllAuxDataTypes must derive from WsfAuxDataEnabled");
161 auto retAuxMapPtr = ut::make_unique<UtScriptMap::Map>();
162 const UtAttributeContainer::AttributeMap& attributes = aObjectPtr->GetAuxDataConst().GetAttributeMap();
163 for (
const auto& aux : attributes)
168 auto* mapRefPtr =
new UtScriptRef(retAuxMapPtr.release(), aReturnClassPtr, UtScriptRef::cMANAGE);
169 aReturnVal.SetPointer(mapRefPtr);
175 static_assert(std::is_base_of<UtScriptClass, SCRIPT_CLASS>::value,
176 "Template type of AddAuxDataScriptMethods must derive from UtScriptClass");
179 aScriptClass.AddMethod(ut::make_unique<typename SCRIPT_CLASS::SetAuxData>());
180 aScriptClass.AddMethod(ut::make_unique<typename SCRIPT_CLASS::AuxDataBool>());
181 aScriptClass.AddMethod(ut::make_unique<typename SCRIPT_CLASS::AuxDataInt>());
182 aScriptClass.AddMethod(ut::make_unique<typename SCRIPT_CLASS::AuxDataDouble>());
183 aScriptClass.AddMethod(ut::make_unique<typename SCRIPT_CLASS::AuxDataString>());
184 aScriptClass.AddMethod(ut::make_unique<typename SCRIPT_CLASS::AuxDataObject>());
185 aScriptClass.AddMethod(ut::make_unique<typename SCRIPT_CLASS::AuxDataExists>());
186 aScriptClass.AddMethod(ut::make_unique<typename SCRIPT_CLASS::AuxDataExists>(
"CheckAuxData"));
187 aScriptClass.AddMethod(ut::make_unique<typename SCRIPT_CLASS::DeleteAuxData>());
188 aScriptClass.AddMethod(ut::make_unique<typename SCRIPT_CLASS::HasAuxData>());
189 aScriptClass.AddMethod(ut::make_unique<typename SCRIPT_CLASS::GetAllAuxDataTypes>());