Component Object Model (COM)
Microsoft has introduced
this standard in 1993. Microsoft has developed this technology by which one
object can talk to another object present at different location using its
methods. This technology is known as COM.
The COM is software
architecture that allows application to be build from binary standard. The
operating system creates the object when they are required and Delete the
object when they are not referred. It is responsibility of an OS to support the
communication between two object located at different place across the network.
Features of COM:
i.
This standard is language
independent.
ii.
It controls another exe on the same
computer.
iii.
It provides the support for the new
protocol such as OLE DB.
iv.
It allows dynamic loading and
unloading of components.
v.
It is capable to communicate with
operating systems.
vi.
It allows shared memory management
between the components.
vii.
It can be provided on multiple
platforms such as Windows XP, Windows NT, Windows 7, Windows 8, UNIX and
MACINTOSH.
Basic Terminologies:
1. Components
(Control):
Components can be referred as objects. This is small code
that provides specific service to rest of the system.
2. VTable
(Virtual function table):
COM defines the virtual function table in the memory. COM use
VTable to call the function.
3. Interface:
The interface is the collection of function through which
application can interact with each other. The name of the interface begins with
prefix “I”. All interfaces in COM are defined from “IUnknown” Interface. This
interface has a pure virtual member function called “Query Interface”.
For Ex:
Struct IUnknown
{
Virtual Bool QueryInterface(int nIid,void ppvobj)=0;
}
Containment and Aggregation
Vs Inheritance:
Containment:
In containment, the component is used as a part of
implementation of new component. That means in containment, the internal copy
of contained object is created so that the internal object is never exposed to
the client.
Aggregation:
When an outer object aggregates an interface of an inner
object, it does not re-implement the interface. It passes the inner object
interface pointer directly to client.
Consider again that the interface IMul need to be accessed by
the client then instead of containing object to call the contained object. The
interface of contained object is directly executed. The inner IMul Interface
can directly accessed by the client.
0 comments:
Post a Comment