Hi Everyone: I'm trying to develop a property list to include as
metadata about my object classes. i.e. I want each class I'm developing
to include a PropertyList which will contain ObjectProperty pointers.
ObjectProperty is a class containing the typeid.name() of a type as
it's ObjectType as well as an ObjectName and ObjectDescripti on.
Basically 3 strings of metadata describing each of a class' member
variables (and hopefully functions) so that the class can report to a
query from another class what properties it has available for access at
run time.
Here is what I have and the error I'm getting:
// ObjectProperty. hpp
#pragma once
#include <string>
#include <list>
#include <typeinfo>
namespace Properties
{
template<typena me aProperty> class ObjectProperty
{
private:
std::string PropertyName;
std::string PropertyType;
std::string PropertyDescrip tion;
public:
ObjectProperty(
const std::string& _PropertyName,
const std::string& _PropertyType,
const std::string& _PropertyDescri ption ):
PropertyName(_P ropertyName),
PropertyType(_P ropertyType),
PropertyDescrip tion(_PropertyD escription){}
ObjectProperty(
const std::string& _PropertyName,
const std::string& _PropertyDescri ption ):
PropertyName(_P ropertyName),
PropertyType(ty peid(aProperty) .name()),
PropertyDescrip tion(_PropertyD escription){}
ObjectProperty( ):
PropertyName(),
PropertyType(ty peid(aProperty) .name()),
PropertyDescrip tion(){}
~ObjectProperty (){}
const std::string& getPropertyName () const
{
return PropertyName;
}
const std::string& getPropertyType () const
{
return PropertyType;
}
const std::string& getPropertyDesc ription() const
{
return PropertyDescrip tion;
}
void setPropertyName ( const std::string& _PropertyName )
{
PropertyName = _PropertyName;
}
void setPropertyType ( const std::string& _PropertyType )
{
PropertyType = _PropertyType;
}
void setPropertyDesc ription( const std::string& _PropertyDescri ption
)
{
PropertyDescrip tion = _PropertyDescri ption;
}
};
// a simple wrapper to have further functionality added
class PropertyList
{
public:
// will be made private later after I get it working :o)
std::list<Objec tProperty*> theProperties;
// public functions such as....
// void displayProperti es();
// const list<ObjectProp erty*>& getProperties() ;
// bool compareProperti es(PropertyList &, PropertyList&);
// ....
};
};
// ObjectPropertyD river.cpp
#include <iostream>
#include "ObjectProperty .hpp"
using namespace Properties;
using namespace std;
int main(void)
{
try
{
// active code
PropertyList pl;
ObjectProperty< char* >* op = new ObjectProperty< char* >("My char*
Property", "My char* Property Description");
pl.thePropertie s.push_back(op) ;
return 0;
}
catch(...) // any old exception not already caught
{
cerr << "OOooops ... unexpected exception\n";
}
}
Error 1 error C2664: 'std::list<_Ty> ::push_back' : cannot convert
parameter 1 from 'Properties::Ob jectProperty<aP roperty> *' to
'Properties::Ob jectProperty *const &' ...\objectprope rtydriver.cpp 15
compiler is devstudio 8.blah....
If I'm going about it completely wrong then a pointer in the right
direction would be helpful, otherwise any suggestions at all are
welcome....
TIA,
LJH.
metadata about my object classes. i.e. I want each class I'm developing
to include a PropertyList which will contain ObjectProperty pointers.
ObjectProperty is a class containing the typeid.name() of a type as
it's ObjectType as well as an ObjectName and ObjectDescripti on.
Basically 3 strings of metadata describing each of a class' member
variables (and hopefully functions) so that the class can report to a
query from another class what properties it has available for access at
run time.
Here is what I have and the error I'm getting:
// ObjectProperty. hpp
#pragma once
#include <string>
#include <list>
#include <typeinfo>
namespace Properties
{
template<typena me aProperty> class ObjectProperty
{
private:
std::string PropertyName;
std::string PropertyType;
std::string PropertyDescrip tion;
public:
ObjectProperty(
const std::string& _PropertyName,
const std::string& _PropertyType,
const std::string& _PropertyDescri ption ):
PropertyName(_P ropertyName),
PropertyType(_P ropertyType),
PropertyDescrip tion(_PropertyD escription){}
ObjectProperty(
const std::string& _PropertyName,
const std::string& _PropertyDescri ption ):
PropertyName(_P ropertyName),
PropertyType(ty peid(aProperty) .name()),
PropertyDescrip tion(_PropertyD escription){}
ObjectProperty( ):
PropertyName(),
PropertyType(ty peid(aProperty) .name()),
PropertyDescrip tion(){}
~ObjectProperty (){}
const std::string& getPropertyName () const
{
return PropertyName;
}
const std::string& getPropertyType () const
{
return PropertyType;
}
const std::string& getPropertyDesc ription() const
{
return PropertyDescrip tion;
}
void setPropertyName ( const std::string& _PropertyName )
{
PropertyName = _PropertyName;
}
void setPropertyType ( const std::string& _PropertyType )
{
PropertyType = _PropertyType;
}
void setPropertyDesc ription( const std::string& _PropertyDescri ption
)
{
PropertyDescrip tion = _PropertyDescri ption;
}
};
// a simple wrapper to have further functionality added
class PropertyList
{
public:
// will be made private later after I get it working :o)
std::list<Objec tProperty*> theProperties;
// public functions such as....
// void displayProperti es();
// const list<ObjectProp erty*>& getProperties() ;
// bool compareProperti es(PropertyList &, PropertyList&);
// ....
};
};
// ObjectPropertyD river.cpp
#include <iostream>
#include "ObjectProperty .hpp"
using namespace Properties;
using namespace std;
int main(void)
{
try
{
// active code
PropertyList pl;
ObjectProperty< char* >* op = new ObjectProperty< char* >("My char*
Property", "My char* Property Description");
pl.thePropertie s.push_back(op) ;
return 0;
}
catch(...) // any old exception not already caught
{
cerr << "OOooops ... unexpected exception\n";
}
}
Error 1 error C2664: 'std::list<_Ty> ::push_back' : cannot convert
parameter 1 from 'Properties::Ob jectProperty<aP roperty> *' to
'Properties::Ob jectProperty *const &' ...\objectprope rtydriver.cpp 15
compiler is devstudio 8.blah....
If I'm going about it completely wrong then a pointer in the right
direction would be helpful, otherwise any suggestions at all are
welcome....
TIA,
LJH.
Comment