473,760 Members | 8,623 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_propertie s;
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 1358
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
2893
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 class). Any comments would be appreciated! Thanks! Steve ----------------------------------------------------------------------
18
14978
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 expensive is it to instantiate/use Generic Dictionaries in great numbers (let's just say 100000's ), in terms of memoryuse and performance? Any practical experiences out there?
5
2284
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) { try { Type objectType = input.GetType(); PropertyInfo properties = objectType.GetProperties();
0
1352
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 with the Domain Model objects. My Domain Model objects are declared this way : public class City /* Inheritance removed for brevity...*/ { private string _Name;
0
5928
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 problem serializing my stuff to XML when it comes to collections. I'm currently using .net2 with generic lists to prevent users putting all sorts of stuff in the arrays (Although im sure i'll be the only user of the classes but not the game, anyway)....
3
6001
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 an interface to a class that must be cast to the appropriate higher level class to use all functionality. Thus I tried to implement a generic cast function for use from the vbscript
10
1939
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 I will need the Generic Class, given there are so many other options. -- cheers,
10
2957
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 generic list of business objects. I'm able to see that the type is the correct one in the debugger. However when I try to traverse the list using the type I can't compile. The same type variable I've verified as being passed
2
4183
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 types derived from that base type, or arrays or generic collections of instances of types derived from that base type. All is well until I come to the properties which are generic collections, I don't seem to be able to find an elegant way of...
0
9333
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9945
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
9900
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
9765
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
8768
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...
0
5214
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
3863
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
3
3442
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.