Click to See Complete Forum and Search --> : How can i implement list of objects in COM
jack
March 31st, 1999, 11:41 AM
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 ??
Eddie
March 31st, 1999, 02:48 PM
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.
Julius Ivanyi
March 31st, 1999, 03:20 PM
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
Dimarzio
March 31st, 1999, 06:20 PM
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.
jack
April 1st, 1999, 12:15 AM
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 ??
Dave Lorde
April 1st, 1999, 04:44 AM
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
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.