473,587 Members | 2,607 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

object architecture,

Hi,

My goal is to display in a graphical application properties of my
objects. To do that I am using on windows a graphical control (MFC)
called EPropCtrl with the following definition :
Expand|Select|Wrap|Line Numbers
  1. class IPropertyHost
  2. {
  3. public:
  4. virtual void GetProperties( EPropList& PropList ) {}
  5. };
  6.  
  7.  
  8. // EPropCtrl : Windows control (MFC) that looks like a ListBox
  9. class EPropCtrl
  10. {
  11. public:
  12. SetPropPointer( IPropertyHost* pHost);
  13. };
  14.  

Pratically when I want to display/modify properties of a simple class
defined like this :

Expand|Select|Wrap|Line Numbers
  1. class Simple
  2. {
  3. protected:
  4. int iValue;
  5. };
  6.  
I just need to create a new class deriving from Simple Class AND from
IPropertyHost like this :

Expand|Select|Wrap|Line Numbers
  1. class SimpleProp : public Simple,
  2. public IPropertyHost
  3. {
  4. public:
  5. virtual void     GetProperties( EPropList& PropList )
  6. {
  7. PropList.AddPropInt(this,_T("iValue"),&iValue, false);
  8. }
  9.  
  10.  
  11.  
  12. IPropertyHost*     GetPropPointer() { return this; }
  13. protected:
  14. int iValue;
  15. };
  16.  
and after to update my control by doing :

EPropCtrl objPropCtrl; // Graphical window to display/edit propertis
SimpleProp simpleProp; //Objet SimpleProp
objPropCtrl.Set PropPointer( simpleProp.GetP ropPointer() );
// --------------- SO FAR EVERYTHING IS OK --------------------------

Now let's consider two objects that wrapps C structures like this :

Expand|Select|Wrap|Line Numbers
  1. typedef struct tagStructB
  2. {
  3. int        iSizeB;
  4. char*      szTextB;
  5. } StructB;
  6.  
  7. typedef struct tagStructA
  8. {
  9. int        iSizeA;
  10. char*      szTextA;
  11.  
  12. StructB sStructB;
  13. } StructA;
  14.  
  15. class B
  16. {
  17. public:
  18. B(structB& refStructB) { m_refStructB = refStructB ;}
  19. int        GetSize() {return m_StructB.iSizeB;}
  20. char*    GetText() {return m_StructB.szTextB;}
  21.  
  22. protected:
  23. structB& m_refStructB;
  24. };
  25.  
  26.  
  27. class A
  28. {
  29. public:
  30. A();
  31. int        GetSize() {return m_StructA.iSizeA;}
  32. char*    GetText() {return m_StructA.szTextA;}
  33. B&        GetB() { return m_B; }
  34.  
  35.  
  36. protected:
  37. structA m_StructA;
  38. B        m_B;
  39. };
  40.  
  41. Example of use :
  42.  
  43. A m_a;
  44. int iSizeA = m_A.GetSize();
  45. m_A.GetB().GetSize();
  46.  
If I am doing the same as the simple example I would do somthing like :

class BProp: public B,
public IPropertyHost
{
public:
virtual void GetProperties( EPropList& PropList )
{
PropList.AddPro pInt(this,_T("i SizeB"),&m_refS tructB.iSizeB, false);
PropList.AddPro pString(this,_T ("szTextB"),&m_ refStructB.szTe xtB, false);

}
IPropertyHost* GetPropPointer( ) { return this; }
};

class AProp: public A,
public IPropertyHost
{
public:
virtual void GetProperties( EPropList& PropList )
{

PropList.AddPro pInt(this,_T("i SizeA"),&m__Str uctA.iSizeA, false);
PropList.AddPro pString(this,_T ("szTextA"),&m_ _StructA.szText A, false);
m_B.GetProperti es( PropList ); // <----- CANNOT WORK
}
IPropertyHost* GetPropPointer( ) { return this; }
};

EPropCtrl objPropCtrl;
AProp objAProp;

objPropCtrl.Set PropPointer( objAProp.GetPro pPointer() );

// PROBLEM : I CANNOT call m_B.GetProperti es( PropList ) to display B
properties from AProp since Aprop has only a B and not a BProp.
HOw should I change my objets to display my properties ??????????????


May 5 '06 #1
5 1655
Vincent RICHOMME wrote:
Hi,

My goal is to display in a graphical application properties of my
objects. To do that I am using on windows a graphical control (MFC)
called EPropCtrl with the following definition :

[long OT post redacted]

You would do better in a newsgroup with MFC or Windows in its name.

See FAQ 5.9 : http://www.parashift.com/c++-faq-lit...t.html#faq-5.9
May 5 '06 #2
Vincent RICHOMME wrote:
My goal is to display in a graphical application properties of my
objects. To do that I am using on windows a graphical control (MFC)
called EPropCtrl with the following definition :
Expand|Select|Wrap|Line Numbers
  1.  class IPropertyHost
  2.  {
  3.  public:
  4.      virtual void GetProperties( EPropList& PropList ) {}
  5.  };
  6.  // EPropCtrl : Windows control (MFC) that looks like a ListBox
  7.  class EPropCtrl
  8.  {
  9.      public:
  10.      SetPropPointer( IPropertyHost* pHost);
  11.  };
  12.  


Pratically when I want to display/modify properties of a simple class
defined like this :

Expand|Select|Wrap|Line Numbers
  1.  class Simple
  2.  {
  3.  protected:
  4.      int iValue;
  5.  };
  6.  

I just need to create a new class deriving from Simple Class AND from
IPropertyHost like this :

Expand|Select|Wrap|Line Numbers
  1.  class SimpleProp : public Simple,
  2.                     public IPropertyHost
  3.  {
  4.  public:
  5.      virtual void     GetProperties( EPropList& PropList )
  6.      {
  7.          PropList.AddPropInt(this,_T("iValue"),&iValue, false);
  8.      }
  9.      IPropertyHost*     GetPropPointer() { return this; }
  10.  protected:
  11.      int iValue;
  12.  };
  13.  
and after to update my control by doing :

EPropCtrl objPropCtrl; // Graphical window to display/edit propertis
SimpleProp simpleProp; //Objet SimpleProp
objPropCtrl.Set PropPointer( simpleProp.GetP ropPointer() );
// --------------- SO FAR EVERYTHING IS OK --------------------------

Now let's consider two objects that wrapps C structures like this :

Expand|Select|Wrap|Line Numbers
  1.  typedef struct tagStructB
  2.  {
  3.      int        iSizeB;
  4.      char*      szTextB;
  5.  } StructB;
  6.  typedef struct tagStructA
  7.  {
  8.      int        iSizeA;
  9.      char*      szTextA;
  10.      StructB sStructB;
  11.  } StructA;
  12.  class B
  13.  {
  14.  public:
  15.      B(structB& refStructB) { m_refStructB = refStructB ;}
  16.      int        GetSize() {return m_StructB.iSizeB;}
  17.      char*    GetText() {return m_StructB.szTextB;}
  18.  protected:
  19.      structB& m_refStructB;
  20.  };
  21.  class A
  22.  {
  23.  public:
  24.      A();
  25.      int        GetSize() {return m_StructA.iSizeA;}
  26.      char*    GetText() {return m_StructA.szTextA;}
  27.      B&        GetB() { return m_B; }
  28.  protected:
  29.      structA m_StructA;
  30.      B        m_B;
  31.  };
  32.  Example of use :
  33.  A m_a;
  34.  int iSizeA = m_A.GetSize();
  35.  m_A.GetB().GetSize();
  36.  

If I am doing the same as the simple example I would do somthing like
:
class BProp: public B,
public IPropertyHost
{
public:
virtual void GetProperties( EPropList& PropList )
{
PropList.AddPro pInt(this,_T("i SizeB"),&m_refS tructB.iSizeB, false);
PropList.AddPro pString(this,_T ("szTextB"),&m_ refStructB.szTe xtB,
false);
}
IPropertyHost* GetPropPointer( ) { return this; }
};

class AProp: public A,
public IPropertyHost
{
public:
virtual void GetProperties( EPropList& PropList )
{

PropList.AddPro pInt(this,_T("i SizeA"),&m__Str uctA.iSizeA, false);
PropList.AddPro pString(this,_T ("szTextA"),&m_ _StructA.szText A, false);
m_B.GetProperti es( PropList ); // <----- CANNOT WORK
}
IPropertyHost* GetPropPointer( ) { return this; }
};

EPropCtrl objPropCtrl;
AProp objAProp;

objPropCtrl.Set PropPointer( objAProp.GetPro pPointer() );

// PROBLEM : I CANNOT call m_B.GetProperti es( PropList ) to display B
properties from AProp since Aprop has only a B and not a BProp.
HOw should I change my objets to display my properties ??????????????


You can make your 'AProp' to keep a 'BProp' instead...

You could change the whole scheme of creating/displaying of properties
to using "visitors" instead of deriving "property-ized" objects from
"regular" ones.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
May 5 '06 #3
red floyd wrote:
Vincent RICHOMME wrote:
Hi,

My goal is to display in a graphical application properties of my
objects. To do that I am using on windows a graphical control (MFC)
called EPropCtrl with the following definition :

[long OT post redacted]

You would do better in a newsgroup with MFC or Windows in its name.

See FAQ 5.9 :
http://www.parashift.com/c++-faq-lit...t.html#faq-5.9


Not really, he wouldn't. The question is not about MFC per se.
Did you bother to read it to the end?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
May 5 '06 #4
Victor Bazarov wrote:
Could You tell me more about your suggestion on visitors ?
Just give me an example starting from what I give. I will try to understand.

thanks

Vincent RICHOMME wrote:
My goal is to display in a graphical application properties of my
objects. To do that I am using on windows a graphical control (MFC)
called EPropCtrl with the following definition :
Expand|Select|Wrap|Line Numbers
  1. class IPropertyHost
  2. {
  3. public:
  4.     virtual void GetProperties( EPropList& PropList ) {}
  5. };
  6. // EPropCtrl : Windows control (MFC) that looks like a ListBox
  7. class EPropCtrl
  8. {
  9.     public:
  10.     SetPropPointer( IPropertyHost* pHost);
  11. };


Pratically when I want to display/modify properties of a simple class
defined like this :

Expand|Select|Wrap|Line Numbers
  1. class Simple
  2. {
  3. protected:
  4.     int iValue;
  5. };

I just need to create a new class deriving from Simple Class AND from
IPropertyHo st like this :

Expand|Select|Wrap|Line Numbers
  1. class SimpleProp : public Simple,
  2.                    public IPropertyHost
  3. {
  4. public:
  5.     virtual void     GetProperties( EPropList& PropList )
  6.     {
  7.         PropList.AddPropInt(this,_T("iValue"),&iValue, false);
  8.     }
  9.     IPropertyHost*     GetPropPointer() { return this; }
  10. protected:
  11.     int iValue;
  12. };
and after to update my control by doing :

EPropCtrl objPropCtrl; // Graphical window to display/edit propertis
SimpleProp simpleProp; //Objet SimpleProp
objPropCtrl.S etPropPointer( simpleProp.GetP ropPointer() );
// --------------- SO FAR EVERYTHING IS OK --------------------------

Now let's consider two objects that wrapps C structures like this :

Expand|Select|Wrap|Line Numbers
  1. typedef struct tagStructB
  2. {
  3.     int        iSizeB;
  4.     char*      szTextB;
  5. } StructB;
  6. typedef struct tagStructA
  7. {
  8.     int        iSizeA;
  9.     char*      szTextA;
  10.     StructB sStructB;
  11. } StructA;
  12. class B
  13. {
  14. public:
  15.     B(structB& refStructB) { m_refStructB = refStructB ;}
  16.     int        GetSize() {return m_StructB.iSizeB;}
  17.     char*    GetText() {return m_StructB.szTextB;}
  18. protected:
  19.     structB& m_refStructB;
  20. };
  21. class A
  22. {
  23. public:
  24.     A();
  25.     int        GetSize() {return m_StructA.iSizeA;}
  26.     char*    GetText() {return m_StructA.szTextA;}
  27.     B&        GetB() { return m_B; }
  28. protected:
  29.     structA m_StructA;
  30.     B        m_B;
  31. };
  32. Example of use :
  33. A m_a;
  34. int iSizeA = m_A.GetSize();
  35. m_A.GetB().GetSize();

If I am doing the same as the simple example I would do somthing like
:
class BProp: public B,
public IPropertyHost
{
public:
virtual void GetProperties( EPropList& PropList )
{
PropList.AddP ropInt(this,_T( "iSizeB"),&m_re fStructB.iSizeB , false);
PropList.AddP ropString(this, _T("szTextB"),& m_refStructB.sz TextB,
false);
}
IPropertyHost* GetPropPointer( ) { return this; }
};

class AProp: public A,
public IPropertyHost
{
public:
virtual void GetProperties( EPropList& PropList )
{

PropList.AddP ropInt(this,_T( "iSizeA"),&m__S tructA.iSizeA, false);
PropList.AddP ropString(this, _T("szTextA"),& m__StructA.szTe xtA, false);
m_B.GetProperti es( PropList ); // <----- CANNOT WORK
}
IPropertyHost* GetPropPointer( ) { return this; }
};

EPropCtrl objPropCtrl;
AProp objAProp;

objPropCtrl.S etPropPointer( objAProp.GetPro pPointer() );

// PROBLEM : I CANNOT call m_B.GetProperti es( PropList ) to display B
properties from AProp since Aprop has only a B and not a BProp.
HOw should I change my objets to display my properties ??????????????

You can make your 'AProp' to keep a 'BProp' instead...

You could change the whole scheme of creating/displaying of properties
to using "visitors" instead of deriving "property-ized" objects from
"regular" ones.

V


May 5 '06 #5
Victor Bazarov wrote:
red floyd wrote:
Vincent RICHOMME wrote:
Hi,

My goal is to display in a graphical application properties of my
objects. To do that I am using on windows a graphical control (MFC)
called EPropCtrl with the following definition :

[long OT post redacted]

You would do better in a newsgroup with MFC or Windows in its name.

See FAQ 5.9 :
http://www.parashift.com/c++-faq-lit...t.html#faq-5.9


Not really, he wouldn't. The question is not about MFC per se.
Did you bother to read it to the end?


Sorry, I saw all this properties stuff, and IThis, IThat and
IAmAnInterface stuff and pretty much figured it was. My apologies to
the OP.

May 5 '06 #6

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

Similar topics

11
9231
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in C++. I find my self sometimes, trying Object app = Object(); Object *app = Object(); Object app = new Object();
2
2202
by: lpw | last post by:
I have dilligently reviewed FAQ-lite Section 3.2, "How do I pass a pointer-to-member-function to a signal handler, X event callback, system call that starts a thread/task, etc." The only suggestion on how to deliver a signal to an object is to do it via a global variable and a wrapper function, a technique that is generally a Bad Idea (due to...
7
1227
by: Chris | last post by:
I'm on a project where the prevoius developer wrote code like below. I thought stuff like this was bad? Isn't he putting a page into a session object? And what we are trying to do is hit the db via a Stored Proc to create a datatable in most cases. This seems like a waste to me. Is this good? Public Shared Function getSQL(ByRef thePage As...
2
2320
by: Julia | last post by:
Hi, Can a Remote object be a WebService as well? i want to able to connect to a remote object either using .NET remoting and HTTP\SOAP so I wonder if I can create a singleton(statefull) object hosted in IIS which can be xml web service ,NET remoted object,singleton and support COM+ transaction management all in the same time
9
3778
by: Greger | last post by:
Hi, I am building an architecture that passes my custom objects to and from webservices. (Our internal architecture requires me to use webservices to any suggestion to use other remoting techniques are not feasible) The question is; Given that I have a Person object with a private set for id. What is the recommended approac in passing...
12
7488
by: Doug | last post by:
Hi, I learned a little about the model view presenter pattern at a conference this last week and am experimenting with it. It's working pretty well but I have a question. I am trying to use it to reset info in a combo box. Below is some sample code for my view interface and the presenter: public interface IDevToolView
1
2014
by: Mike H | last post by:
I can't seem to figure out the right thing to search on, so I thought I'd just provide an example and see if someone can point me to some tips. What I have is an Automation Server that has a method that will start another automation server. These Activex automation servers that it talks to require a specific interface that the calling...
0
1307
by: rsdev | last post by:
Hi, I am new to ASP.NET and I am trying to build a CMS application using theBeerHouse SK. I am adapting the Datareader to collect information from an SQL database and send it to an HtmlHeader. Using N-Tier architecture I keep recieving an object reference required error. Here's my code: Home.aspx.cs
7
1688
by: joproulx | last post by:
Hi, I was wondering if there was a way with Reflection to find dynamically if an object was referencing indirectly another object. A simple example would be: Object1 | --Object2 |
275
12170
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
7918
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...
0
7843
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...
0
8340
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...
1
7967
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...
0
8220
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...
1
5713
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...
0
3840
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...
0
3875
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.