src/linetypes/object.h

changeset 150
b6cbba6e29a1
parent 148
e1ced2523cad
child 158
5bd755eaa5a8
equal deleted inserted replaced
148:e1ced2523cad 150:b6cbba6e29a1
84 template<Property property, typename Function> 84 template<Property property, typename Function>
85 void handle(SetPropertyResult* result, const PropertyKeyValue& pair, Function function); 85 void handle(SetPropertyResult* result, const PropertyKeyValue& pair, Function function);
86 virtual void setProperty(SetPropertyResult* result, const PropertyKeyValue& pair); 86 virtual void setProperty(SetPropertyResult* result, const PropertyKeyValue& pair);
87 }; 87 };
88 88
89 /**
90 * @brief Tests whether the object is exactly of the specified type
91 * @tparam R Type of LDraw line type object to test for
92 * @param object Object to test
93 * @returns whether the type of the object specified by @c id is the same type as R. Returns false if it is a subclass.
94 */
95 template<typename R>
96 bool isA(const ldraw::Object* object)
97 {
98 const std::type_info& a = typeid(*object);
99 const std::type_info& b = typeid(R);
100 return a == b;
101 }
102
89 template<ldraw::Property property> 103 template<ldraw::Property property>
90 ldraw::Object::SetPropertyResult ldraw::Object::setProperty(const ldraw::PropertyType<property>& value) 104 ldraw::Object::SetPropertyResult ldraw::Object::setProperty(const ldraw::PropertyType<property>& value)
91 { 105 {
92 SetPropertyResult result = SetPropertyResult::PropertyNotHandled; 106 SetPropertyResult result = SetPropertyResult::PropertyNotHandled;
93 this->setProperty(&result, PropertyKeyValue{property, QVariant::fromValue(value)}); 107 this->setProperty(&result, PropertyKeyValue{property, QVariant::fromValue(value)});

mercurial