473,513 Members | 2,492 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.SetPropPointer( simpleProp.GetPropPointer() );
// --------------- 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.AddPropInt(this,_T("iSizeB"),&m_refStruct B.iSizeB, false);
PropList.AddPropString(this,_T("szTextB"),&m_refSt ructB.szTextB, false);

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

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

PropList.AddPropInt(this,_T("iSizeA"),&m__StructA. iSizeA, false);
PropList.AddPropString(this,_T("szTextA"),&m__Stru ctA.szTextA, false);
m_B.GetProperties( PropList ); // <----- CANNOT WORK
}
IPropertyHost* GetPropPointer() { return this; }
};

EPropCtrl objPropCtrl;
AProp objAProp;

objPropCtrl.SetPropPointer( objAProp.GetPropPointer() );

// PROBLEM : I CANNOT call m_B.GetProperties( 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 1648
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.SetPropPointer( simpleProp.GetPropPointer() );
// --------------- 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.AddPropInt(this,_T("iSizeB"),&m_refStruct B.iSizeB, false);
PropList.AddPropString(this,_T("szTextB"),&m_refSt ructB.szTextB,
false);
}
IPropertyHost* GetPropPointer() { return this; }
};

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

PropList.AddPropInt(this,_T("iSizeA"),&m__StructA. iSizeA, false);
PropList.AddPropString(this,_T("szTextA"),&m__Stru ctA.szTextA, false);
m_B.GetProperties( PropList ); // <----- CANNOT WORK
}
IPropertyHost* GetPropPointer() { return this; }
};

EPropCtrl objPropCtrl;
AProp objAProp;

objPropCtrl.SetPropPointer( objAProp.GetPropPointer() );

// PROBLEM : I CANNOT call m_B.GetProperties( 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
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. };
and after to update my control by doing :

EPropCtrl objPropCtrl; // Graphical window to display/edit propertis
SimpleProp simpleProp; //Objet SimpleProp
objPropCtrl.SetPropPointer( simpleProp.GetPropPointer() );
// --------------- 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.AddPropInt(this,_T("iSizeB"),&m_refStru ctB.iSizeB, false);
PropList.AddPropString(this,_T("szTextB"),&m_ref StructB.szTextB,
false);
}
IPropertyHost* GetPropPointer() { return this; }
};

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

PropList.AddPropInt(this,_T("iSizeA"),&m__Struct A.iSizeA, false);
PropList.AddPropString(this,_T("szTextA"),&m__St ructA.szTextA, false);
m_B.GetProperties( PropList ); // <----- CANNOT WORK
}
IPropertyHost* GetPropPointer() { return this; }
};

EPropCtrl objPropCtrl;
AProp objAProp;

objPropCtrl.SetPropPointer( objAProp.GetPropPointer() );

// PROBLEM : I CANNOT call m_B.GetProperties( 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
9213
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...
2
2191
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...
7
1220
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...
2
2311
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)...
9
3771
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...
12
7478
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...
1
2009
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...
0
1304
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. ...
7
1685
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
12039
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
7260
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,...
0
7161
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...
0
7525
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...
1
5089
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...
0
4746
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...
0
3234
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...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1596
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 ...
1
802
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.