Re: How to access COM objects' internal data?
"Boris" <boris@gtemail.net> wrote in message
news:op.tz00ky1s45fww6@burk.mshome.net
On Thu, 11 Oct 2007 02:31:15 +0300, Igor Tandetnik
<itandetnik@mvps.org> wrote:
[...]
Furthermore users of the library will see functions which are meant
only to be used internally.
I don't understand. If you don't want them publicly available, don't
expose them on a public COM interface. What again seems to be the
problem?
Imagine a workbook in Excel which provides access to the worksheets
collection. If the workbook is loaded it might want to initialize the
worksheets collection (eg. storing the worksheet names in m_coll in
the collection). Now how should this be done ideally?
Presumably, the workbook object would create worksheet objects based on
the contents of XLS file as it's being loaded, and store them in its
collection. It would likely store a direct C++ pointer to the
implementation class, not a COM interface pointer.
Shall the
workbook which is another interface call functions of the interface
worksheets
Again, since workbook has created the worksheets in the first place, it
has direct C++ pointer to them, and thus can access functionality not
exposed on public COM interfaces.
COM is intended as an interface between loosely coupled modules. It is
not designed to be used between two tightly coupled components within a
single module.
Or shall the workbook
assume that the interface worksheets is implemented by a concrete
Excel COM class
Why "assume"? After all, the workbook has just done something like "new
WorkSheet" - it's pretty sure what class implements the worksheet.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925