473,778 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pointers for these pointers...?

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.

Feb 6 '06 #1
2 1313
DirtyClamDigger wrote:
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:
I'm not entirely clear on what you're doing (and I haven't spent
sufficient time looking) but I this might help. See below:
// 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; // ITYM:
std::list<Objec tProperty<aProp erty>*> theProperties;

// as ObjectProperty is a templated class
// 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....

See above.

HTH,
--ag
--
Artie Gold -- Austin, Texas
http://goldsays.blogspot.com (new post 8/5)
http://www.cafepress.com/goldsays
"If you have nothing to hide, you're not trying!"
Feb 7 '06 #2
Thanks, Artie, but that doesn't seem to work either. What is bugging me
is that if I comment out the push_back call in the code above then it
compiles and runs fine. I'm simply trying to find a way to have a
property list associated with each class I create so that I can query
objects of that class as to the descriptions of their data. i.e. data
about the data is called 'meta'data. In my mind that means having a
static list of name/type/description triplets describing the
datamembers of a class..

e.g. // this code is just off the top of my head to demo my
intent...don't expect correctness! :o)

class aClass{
public:

int anInt;
double aDouble;
static PropertyList dataProperties;

//...class def'ns etc...
void loadProperites( ){
ObjectProperty* <double> op = new ObjectProperty< double>("aDoubl e", "A
Double defined for this dummy class);
dataProperties. push_back(*op);
}
};...//end class

Anyway, I tried your suggestion and it still fetches up with a type
mismatch error. I guess I'm going to have to sit and think on it a bit
more....

Thanks anyway.

regards,
LJH

Feb 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
3412
by: Susan Baker | last post by:
Hi, I'm just reading about smart pointers.. I have some existing C code that I would like to provide wrapper classes for. Specifically, I would like to provide wrappers for two stucts defined as ff: typedef struct { float *data ; int count ;
388
21929
by: maniac | last post by:
Hey guys, I'm new here, just a simple question. I'm learning to Program in C, and I was recommended a book called, "Mastering C Pointers", just asking if any of you have read it, and if it's worth the $25USD. I'm just looking for a book on Pointers, because from what I've read it's one of the toughest topics to understand. thanks in advanced.
20
2976
by: fix | last post by:
Hi all, I feel unclear about what my code is doing, although it works but I am not sure if there is any possible bug, please help me to verify it. This is a trie node (just similar to tree nodes) struct, I am storing an array of 27 pointers and a void pointer that can point to anything. typedef struct trieNode { struct trieNode *children; // The children nodes void *obj; // The object stored } TrieNode;
8
448
by: John Hanley | last post by:
I working in C. I haven't paid much attention to void pointers in the past, but I am wondering if I can use them for my various linked lists to save work. I have two different linked lists that each use nodes of different structs. However the principle of my adding to the linked lists and removing them is the same. So will it work to have these functions accept a void pointer as an argument for the list and a void pointer as an...
9
5067
by: Mikhail Teterin | last post by:
Hello! I'd like to have a variable of a pointer-to-function type. The two possible values are of type (*)(FILE *) and (*)(void *). For example: getter = straight ? fgetc : gzgetc; nextchar = getter(file); What type should I give to `getter' so that the compiler does not issue
11
2202
by: junky_fellow | last post by:
Do all double pointers have same size on a particular implementation. eg char **c_ptr; int **i_ptr; Is the size of c_ptr and i_ptr always same (on same implementation) or it may be different ?
11
518
by: subramanian100in | last post by:
Given that the sizes of pointers to different data types(built-in or structures) can be different, though malloc returns a void *, it is assigned to any pointer type. The language allows it. From this, can I conclude that the size of (void *) should be the maximum ? If this is not the case, consider the following scenario. Suppose there is a type T (built-in or structure) whose pointer size is bigger than the sizeof (void *) ie sizeof (T...
25
13059
by: J Caesar | last post by:
In C you can compare two pointers, p<q, as long as they come from the same array or the same malloc()ated block. Otherwise you can't. What I'd like to do is write a function int comparable(void *p, void *q) that will take any two pointers and decide whether they can be compared or not. I really can't think how to do this - any suggestions?
3
1680
by: Scotty | last post by:
I'm a C++ novice and need help figuring out some odd behavior I've encountered. Here's the situation: I create a class and have its constructor store a random number in a private "number" variable. The class also has a "getNumber()" function that returns its stored number. A function in the program creates five objects of this class and five pointers to these objects, the latter of which are stored in a global array. When "getNumber()"...
54
12019
by: Boris | last post by:
I had a 3 hours meeting today with some fellow programmers that are partly not convinced about using smart pointers in C++. Their main concern is a possible performance impact. I've been explaining the advantages of smart pointers endlessly (which are currently used in all our C++ software; we use the Boost smart pointers) as I'm seriously concerned that there is a shift to raw pointers. We are not developing system software but rather...
0
9628
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10122
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10061
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9923
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8954
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7471
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6722
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5368
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4031
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.