How to use COM in such condition?
-
im a com beginner, i know its more complex than normal usage. Here i list some classes as following: class A{ //...some member variables, such as c strings, and other class variables }; class B{ //...some member variables, such as c strings, and other class variables }; class C{ //...some member variables, such as c strings, and other class variables A* m_pAobjects; B* m_pBobjects; }; In the project, there would be only one instance of class C, but there would be more than one B instances and A instance; And i can create one C instance, which will read some data from some files or generate some data on the fly; and i can get the count of its internal A or B instances, retrieve specified objects from the instances. But, i don't know how to design the project to com architecture. My main problem is,how to design and implement the interfaces? and how to transfer the parameters between the com client and the server? thanks
-
im a com beginner, i know its more complex than normal usage. Here i list some classes as following: class A{ //...some member variables, such as c strings, and other class variables }; class B{ //...some member variables, such as c strings, and other class variables }; class C{ //...some member variables, such as c strings, and other class variables A* m_pAobjects; B* m_pBobjects; }; In the project, there would be only one instance of class C, but there would be more than one B instances and A instance; And i can create one C instance, which will read some data from some files or generate some data on the fly; and i can get the count of its internal A or B instances, retrieve specified objects from the instances. But, i don't know how to design the project to com architecture. My main problem is,how to design and implement the interfaces? and how to transfer the parameters between the com client and the server? thanks
As a start: Find something on Unified Modelling Language (UML) related to COM, though be careful as some UML descriptions can get a bit complicated. Basically get some paper, draw your COM objects as boxes and any interface such as IUnknown or IMySettings as, well, 'lollipop' or spoon shapes on those boxes. Find a few examples and you'l see what I mean. Then try a sequence diagram to show the messages (calls) between the COM objects. Once you're satisfied you have the messages sorted you need to design interfaces to provide methods which convey those messages.
-
As a start: Find something on Unified Modelling Language (UML) related to COM, though be careful as some UML descriptions can get a bit complicated. Basically get some paper, draw your COM objects as boxes and any interface such as IUnknown or IMySettings as, well, 'lollipop' or spoon shapes on those boxes. Find a few examples and you'l see what I mean. Then try a sequence diagram to show the messages (calls) between the COM objects. Once you're satisfied you have the messages sorted you need to design interfaces to provide methods which convey those messages.
This sort of thing: [^]
-
As a start: Find something on Unified Modelling Language (UML) related to COM, though be careful as some UML descriptions can get a bit complicated. Basically get some paper, draw your COM objects as boxes and any interface such as IUnknown or IMySettings as, well, 'lollipop' or spoon shapes on those boxes. Find a few examples and you'l see what I mean. Then try a sequence diagram to show the messages (calls) between the COM objects. Once you're satisfied you have the messages sorted you need to design interfaces to provide methods which convey those messages.
im agree with you. Although i know little about uml, im puzzled by this condition. But it can be designed in plain C++ easily. About COM, at this condition, class C can be implements as interface C is easy, but how to retrieve its internal instances B or A? No matter C delegate A and B or C contain B and C, there would be more than one interfaces be created...... i think i have not understand the between COM interface and COM object.
-
As a start: Find something on Unified Modelling Language (UML) related to COM, though be careful as some UML descriptions can get a bit complicated. Basically get some paper, draw your COM objects as boxes and any interface such as IUnknown or IMySettings as, well, 'lollipop' or spoon shapes on those boxes. Find a few examples and you'l see what I mean. Then try a sequence diagram to show the messages (calls) between the COM objects. Once you're satisfied you have the messages sorted you need to design interfaces to provide methods which convey those messages.
-
thanks for you advise. After i read the implement about ADO database, i know how to designed such com interfaces for such condition.
As you mention, you can't really consider designing how to implement COM objects in, say, C++ until you are up to speed with COM Objects and Interfaces and have some idea of how they can be used.
-
As you mention, you can't really consider designing how to implement COM objects in, say, C++ until you are up to speed with COM Objects and Interfaces and have some idea of how they can be used.
yes. im just a newbie for com. But the question is upgrading, although i had learnt how to implement it from ADO. Here, class A has B type member pointer, but B is a union type, which can point to a A object or anther different object: class A{ //some other members struct B* m_pB; }; struct B{ int type;//indicate the type of next field union{ char* szText; class A* pA; }data; }; if i translate it to interface, that, i can get IB from IA, but if IB instance's data field point to any IA object, how should i get the IA object? if i get IA object as normal, the previous IA object,the owner of IB, would lost its attributes! right?
-
yes. im just a newbie for com. But the question is upgrading, although i had learnt how to implement it from ADO. Here, class A has B type member pointer, but B is a union type, which can point to a A object or anther different object: class A{ //some other members struct B* m_pB; }; struct B{ int type;//indicate the type of next field union{ char* szText; class A* pA; }data; }; if i translate it to interface, that, i can get IB from IA, but if IB instance's data field point to any IA object, how should i get the IA object? if i get IA object as normal, the previous IA object,the owner of IB, would lost its attributes! right?
Your Inside COM should tell you most of this. Again concentrate on COM objects and Interfaces or some examples and you will realise how to phrase 'IB instance's data field' in COM terms.
-
Your Inside COM should tell you most of this. Again concentrate on COM objects and Interfaces or some examples and you will realise how to phrase 'IB instance's data field' in COM terms.