CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 1999
    Posts
    8

    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 ??

  2. #2
    Join Date
    Mar 1999
    Posts
    7

    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.

  3. #3
    Join Date
    Apr 1999
    Posts
    15

    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

  4. #4
    Join Date
    Mar 1999
    Posts
    9

    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.

  5. #5
    Join Date
    Apr 1999
    Posts
    8

    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 ??

  6. #6
    Join Date
    Apr 1999
    Posts
    383

    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
  •  





Click Here to Expand Forum to Full Width

Featured