|
-
March 31st, 1999, 12:41 PM
#1
How can i implement list of objects in COM
In MFC programming, i use link list to implement dynamic allocated objects.
However in COM, how can i implement that ?? for example, if i'm writing an
application for handling employee's details.
Should i write a COM for holding things about an employee and expose interface
for handling the details ??
How do i implement a collection objects of employees ?? Should i call
CoCreateInstance multiple times for employees, and store interface pointers
for every employee ??
-
March 31st, 1999, 03:48 PM
#2
Re: How can i implement list of objects in COM
There is an standard interface ( I can´t remember now its name ) wich implements generic collections in COM. If it doesn´t match what you need, you can always make a simple interface wich provides iteration throught a list of interface pointers. I think it´s the standard way for managing collections in COM.
-
March 31st, 1999, 04:20 PM
#3
Re: How can i implement list of objects in COM
Hi
I would try to write a COM for employee list, with an [out] interface for a long
that would give you the number of employees and a [out] pointer to an employee
array, the number of items of which are defined in the long variable. The server
could look up the list, create the array and send back to the client.
HTH
Julius
-
March 31st, 1999, 07:20 PM
#4
Re: How can i implement list of objects in COM
Build a simple COM component that internally uses std::vector or something, give the components interface members like Next, Back, GetAt, etc.. that act on that internal vector member. You could use ATL's CSimpleMap or CSimpleArray in place of vector. Any list type container would work. You then pass the interface to the client and it can iterate across the array via the "wrapper" members.
-
April 1st, 1999, 01:15 AM
#5
Re: How can i implement list of objects in COM
How about if I want to implement "invoice" ??? there should be many things in an
invoice, and functions to deal with calculation. Should i implement each invoice
as a conventional class object, and wrapped the collection with COM ?? or each
invoice is a COM ??
-
April 1st, 1999, 05:44 AM
#6
Re: How can i implement list of objects in COM
When you are creating multiple instances, it is more efficient to obtain a pointer to the class object's IClassFactory interface and use the CoGetClassObject function.
Dave
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|