D
DirtyClamDigger
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 ObjectDescription.
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<typename aProperty> class ObjectProperty
{
private:
std::string PropertyName;
std::string PropertyType;
std::string PropertyDescription;
public:
ObjectProperty(
const std::string& _PropertyName,
const std::string& _PropertyType,
const std::string& _PropertyDescription ):
PropertyName(_PropertyName),
PropertyType(_PropertyType),
PropertyDescription(_PropertyDescription){}
ObjectProperty(
const std::string& _PropertyName,
const std::string& _PropertyDescription ):
PropertyName(_PropertyName),
PropertyType(typeid(aProperty).name()),
PropertyDescription(_PropertyDescription){}
ObjectProperty():
PropertyName(),
PropertyType(typeid(aProperty).name()),
PropertyDescription(){}
~ObjectProperty(){}
const std::string& getPropertyName() const
{
return PropertyName;
}
const std::string& getPropertyType() const
{
return PropertyType;
}
const std::string& getPropertyDescription() const
{
return PropertyDescription;
}
void setPropertyName( const std::string& _PropertyName )
{
PropertyName = _PropertyName;
}
void setPropertyType( const std::string& _PropertyType )
{
PropertyType = _PropertyType;
}
void setPropertyDescription( const std::string& _PropertyDescription
)
{
PropertyDescription = _PropertyDescription;
}
};
// a simple wrapper to have further functionality added
class PropertyList
{
public:
// will be made private later after I get it working )
std::list<ObjectProperty*> theProperties;
// public functions such as....
// void displayProperties();
// const list<ObjectProperty*>& getProperties();
// bool compareProperties(PropertyList&, PropertyList&);
// ....
};
};
// ObjectPropertyDriver.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.theProperties.push_back(op);
return 0;
}
catch(...) // any old exception not already caught
{
cerr << "OOooops ... unexpected exception\n";
}
}
Error 1 error C2664: 'std::list<_Ty>:ush_back' : cannot convert
parameter 1 from 'Properties::ObjectProperty<aProperty> *' to
'Properties::ObjectProperty *const &' ...\objectpropertydriver.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 ObjectDescription.
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<typename aProperty> class ObjectProperty
{
private:
std::string PropertyName;
std::string PropertyType;
std::string PropertyDescription;
public:
ObjectProperty(
const std::string& _PropertyName,
const std::string& _PropertyType,
const std::string& _PropertyDescription ):
PropertyName(_PropertyName),
PropertyType(_PropertyType),
PropertyDescription(_PropertyDescription){}
ObjectProperty(
const std::string& _PropertyName,
const std::string& _PropertyDescription ):
PropertyName(_PropertyName),
PropertyType(typeid(aProperty).name()),
PropertyDescription(_PropertyDescription){}
ObjectProperty():
PropertyName(),
PropertyType(typeid(aProperty).name()),
PropertyDescription(){}
~ObjectProperty(){}
const std::string& getPropertyName() const
{
return PropertyName;
}
const std::string& getPropertyType() const
{
return PropertyType;
}
const std::string& getPropertyDescription() const
{
return PropertyDescription;
}
void setPropertyName( const std::string& _PropertyName )
{
PropertyName = _PropertyName;
}
void setPropertyType( const std::string& _PropertyType )
{
PropertyType = _PropertyType;
}
void setPropertyDescription( const std::string& _PropertyDescription
)
{
PropertyDescription = _PropertyDescription;
}
};
// a simple wrapper to have further functionality added
class PropertyList
{
public:
// will be made private later after I get it working )
std::list<ObjectProperty*> theProperties;
// public functions such as....
// void displayProperties();
// const list<ObjectProperty*>& getProperties();
// bool compareProperties(PropertyList&, PropertyList&);
// ....
};
};
// ObjectPropertyDriver.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.theProperties.push_back(op);
return 0;
}
catch(...) // any old exception not already caught
{
cerr << "OOooops ... unexpected exception\n";
}
}
Error 1 error C2664: 'std::list<_Ty>:ush_back' : cannot convert
parameter 1 from 'Properties::ObjectProperty<aProperty> *' to
'Properties::ObjectProperty *const &' ...\objectpropertydriver.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.