Libcom Documentation

From LSDevLinux
Jump to: navigation, search

Documentation for libcom. (This documentation is a work in progress)

Features

libcom supports any mix of C/C++ and .NET clients and servers. So, for example, a C++ COM client can use a C++ COM server, a C++ COM client can use a .NET COM server, a .NET COM client can use a C++ COM server, etc.

components map

You'll need to make a components.map which associates GUIDs to library files. When you run your client, you will need to specify the location of the components.map files in a COMPONENTS_MAP_PATH environment variable.

For example,

$ COMPONENTS_MAP_PATH=../dir1:../dir2 ./client

Related COM servers can be grouped together in a directory with a components.map for all COM servers in that directory. So for example, /usr/lib/FieldWorks/Common/ and /usr/lib/FieldWorks/TE/ might each contain one components.map and several .so shared object files.

For example, for the following tree of files

/usr/lib/FieldWorks/Common/FwKernel.so
/usr/lib/FieldWorks/Common/views.so
/usr/lib/FieldWorks/Common/SimpleRootSite.dll
/usr/lib/FieldWorks/Common/components.map
/usr/lib/FieldWorks/TE/TE.dll
/usr/lib/FieldWorks/TE/TeExport.dll
/usr/lib/FieldWorks/TE/TE.exe
/usr/lib/FieldWorks/TE/components.map

one might use a command such as

$ COMPONENTS_MAP_PATH=/usr/lib/FieldWorks/Common:/usr/lib/FieldWorks/TE mono /usr/lib/FieldWorks/TE/TE.exe

Examples

During development, some simple IDL, C/C++, and C# code was written to test needed functionality of libcom. This code is in the test directory and should serve as a rough example of how to use libcom. The example/test code isn't very polished at the moment; some of it is very old and crufty and is not an example of good COM programming in general but should demonstrate how to make a program use libcom.

Because libcom was written to be a drop-in replacement for certain functionality of Microsoft COM, it should hopefully not require a lot of changes to code that already works with Microsoft COM.

Take note of test/Makefile.am for how things get built.

Here is a table showing which files use C/C++ or C# COM clients or servers.

Client Server Files
C/C++ C/C++
  • CClient.cc, Ball
  • Bag is a COM client to a Ball COM server (see Bag::ProvideBall, Bag::InspectBall), tho this happens when invoked by Tester.cs.
C# C/C++
  • ComClient.cs, Ball
  • Tester.cs, Bag, Ball, Wall
  • BakeryJarTestClient.cs, Bakery
C/C++ C# Bakery is a C++ COM client to a Jar C# COM server
C# C# BakeryJarTestClient.cs, Jar [Actually this might just be bypassing COM]

Note that the Wall test isn't finished and prints some garbage characters.

See also