Making an accessor attribute for an XML resource ref

Hello everyone! :smiley:

The title should be self explanatory, even though let me give some background:

I had a working accessor attribute for an XML resource file and now with the changed macros I’m not able to set it right.

Before I had:

Now I’ve changed it to:

But that isn’t compiling, and gcc is not being helpful at all to point out the error:


.../Urho3D/Source/Engine/Scene/Serializable.h:262:316: error: no matching function for call to ?Urho3D::AttributeAccessorImpl<MapProperties, Urho3D::ResourceRef, Urho3D::AttributeTrait<Urho3D::ResourceRef> >::AttributeAccessorImpl(Urho3D::ResourceRef (MapProperties::*)() const, void (MapProperties::*)(Urho3D::ResourceRef))?
 #define ACCESSOR_ATTRIBUTE(name, getFunction, setFunction, typeName, defaultValue, mode) context->RegisterAttribute<ClassName>(Urho3D::AttributeInfo(GetVariantType<typeName >(), name, new Urho3D::AttributeAccessorImpl<ClassName, typeName, AttributeTrait<typeName > >(&ClassName::getFunction, &ClassName::setFunction), defaultValue, mode))
                                                                                                                                                                                                                                                                                                                            ^
.../Source/Components/Map/Properties/MapProperties.cpp:14:5: note: in expansion of macro ?ACCESSOR_ATTRIBUTE?
     ACCESSOR_ATTRIBUTE("Map data", GetXmlAttr, SetXmlAttr, ResourceRef, ResourceRef(XMLFile::GetTypeStatic()), AM_DEFAULT);
     ^
.../Source/Engine/Scene/Serializable.h:262:316: note: candidate is:
 #define ACCESSOR_ATTRIBUTE(name, getFunction, setFunction, typeName, defaultValue, mode) context->RegisterAttribute<ClassName>(Urho3D::AttributeInfo(GetVariantType<typeName >(), name, new Urho3D::AttributeAccessorImpl<ClassName, typeName, AttributeTrait<typeName > >(&ClassName::getFunction, &ClassName::setFunction), defaultValue, mode))

There’s more of it if it’s really relevant to solve the issue… (I’m not a huge fan of g++).

Thank you very much!

EDIT:

I’ve found this line searching the sources (Light.cpp):

MIXED_ACCESSOR_ATTRIBUTE("Attenuation Texture", GetRampTextureAttr, SetR ampTextureAttr, ResourceRef, ResourceRef(Texture2D::GetTypeStatic()), AM_DEFAULT);

I don’t know what a MIXED_ACCESSOR_ATTRIBUTE is but changing it doesn’t seem to solve the question. Anyway, what’s a mixed accessor attribute?

The answer to your second question is in Serializable.h:

/// Define an attribute that uses get and set functions.
#define ACCESSOR_ATTRIBUTE(name, getFunction, setFunction, typeName, defaultValue, mode)
/// Define an attribute that uses get and set functions, where the get function returns by value, but the set function uses a reference.
#define MIXED_ACCESSOR_ATTRIBUTE(name, getFunction, setFunction, typeName, defaultValue, mode)

Also make sure to follow the specific notes found in Serializable.h:

// The following macros need to be used within a class member function such as ClassName::RegisterObject(). // A variable called "context" needs to exist in the current scope and point to a valid Context object.