473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

generic properties from objects

Lets assume I want to write a whole host of classes having "property"
elements in them and create a bunch of objects from the different classes.
Lets suppose that they are circles, lines, etc... and I display them on the
screen for the user. Now I want to have a window that allows the user to
modify all the "properties" of the object.

It is very similar in how VS.net has a window pane that lets you modify the
different default values of data types in a class.
Is there an easy way of doing this?

example:

class A
{
public:
Set_Prop1(int val)
{
prop1 = val;
};
properties:
private int prop1<'A'=1, 'B'=3>
};

the properties clause basicaly says that prop1 is a property of that class
and can take on the value 'A' or 'B' each translating in the 1 or 3.

Then say I want to display all the properties of A I could do something like

int i = A.num_properties;
while(i > 0)
{
i--;

cout << A.properties[i].name;
for(int j = 0; j < A.properties[i].num_elements; j++)
{
cout << A.properties[i].element_name[j];
cout << A.properties[i].element_val[j];
}
}

[the display would be something like this]

prop1
A B
1 3

or something like that(I know its not valid C++ code but just to give an
idea of what I want to do). If you can't do it in C++ easily can you do it
in C#? I'm looking for a way to do this with the least amount of hassle. (I
could do this, say, by writing out all the properties in an XML file and
having a class load that and use that for the information.. but then if I
change the properties of the class I have to go modify the xml, etc....)

Thanks
Jon

(I figure that it might be possible with templates, but I'm just relearning
the basics of those and I can't think about how to use them to do it)
Jul 23 '05 #1
2 1342
Jon Slaughter wrote:
Lets assume I want to write a whole host of classes having "property"
elements in them and create a bunch of objects from the different classes.
Lets suppose that they are circles, lines, etc... and I display them on the
screen for the user. Now I want to have a window that allows the user to
modify all the "properties" of the object.

It is very similar in how VS.net has a window pane that lets you modify the
different default values of data types in a class.

Is there an easy way of doing this?


You find many 'Properties in C++' approaches on the internet, e.g.
http://www.open-std.org/jtc1/sc22/wg...2004/n1615.pdf

Jul 23 '05 #2
I found this site that sorta seems to do what I am looking for:

http://www.codeproject.com/cpp/cppproperties.asp

The problem is that it says that it creates a property object for each new
property... is there any way to fix this?

Thanks
Jon
Jul 23 '05 #3

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

Similar topics

49
by: Steven Bethard | last post by:
I promised I'd put together a PEP for a 'generic object' data type for Python 2.5 that allows one to replace __getitem__ style access with dotted-attribute style access (without declaring another...
18
by: Rune B | last post by:
Hi Group I was considering using a Generic Dictionary<> as a value container inside my business objects, for the reason of keeping track of fields changed or added and so on. - But how...
5
by: Metaman | last post by:
I'm trying to write a generic method to generate Hashcodes but am having some problems with (generic) collections. Here is the code of my method: public static int GetHashCode(object input) {...
0
by: Mathieu Cartoixa | last post by:
Hi, I have a simple 2-tiers (client+database) application with simple Domain Model objects The Data Access Layer is abstracted via Data Mappers which use Data Transfer Objects to communicate...
0
by: crazyone | last post by:
I've got a gaming framework i'm building and i want to save myself the trouble of reading and writting the complete game data to a custom file and load/save it to an XML file but i'm getting...
3
by: =?Utf-8?B?TWlydHVs?= | last post by:
Hi I'm currently working with vbscripting through MSScriptControl. We have shared some of our objects that should be available for scripting. Some of the functions of these objects will return...
10
by: Egghead | last post by:
Hi all, Can someone kindly enough point me to some situations that we shall or "must" use Generic Class? I can foresee the Generic Method is powerful, but I can not find a single situation that...
10
by: fig000 | last post by:
HI, I'm new to generics. I've written a simple class to which I'm passing a generic list. I'm able to pass the list and even pass the type of the list so I can use it to traverse it. It's a...
2
by: SimonDotException | last post by:
I am trying to use reflection in a property of a base type to inspect the properties of an instance of a type which is derived from that base type, when the properties can themselves be instances of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...

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.