Articles     Forum     Examples     Download     Open Source

 

PocoCapsule/C++ example: Basic-IoC GPS

Copyright(c) 2006 by Pocomatic Software. All rights reserved.

This example was originated from an OMG's tutorial designed for CORBA Component Model (CCM). It models a GPS instrument consists of the following three components implemented as Plain Old C++ objects (POCO) and wired together, as illustrated in the diagram below:


These three components (beans) are instantiated, configured and wired up inside a PocoCapsule/C++ IoC container using PocoCapsule/C++ IoC core schema description setup.xml. The same example using a more express domain-specific-modeling (DSM) schema can be found in the ${POCOCAPSULE_DIR}/examples/corba/dsl-gps directory.

Source Files

main.C: This is a simple container used to assemble the GPS application. Notably, this container itself is completely decoupled from application bean implementations. It does not include/use their source code or link with their binaries.

Interfaces.h: C++ interfaces (as pure virtual C++ classes) definitions of component beans. Note: an equivalent CORBA version of this example, that uses IDL to define component interfaces, can be found in the ${POCOCAPSULE_DIR}/examples/corba/gps directory.

TickGenImpl.h and TickGenImpl.C: The implementation of tick generator device bean class.

GPSLocatorImpl.h and GPSLocatorImpl.C: The implementation of GPS locator device bean class.

NavDisplayImpl.h and NavDisplayImpl.C: The implementation of Navigate Display device bean class. It is also notable that above three application implementation POCO beans themselves are container agnostic. It does not use, nor link with PocoCapsule/C++ container runtime engine. They are plain old C++ objects can be developed and tested completely independent of and unaware of PocoCapsule/C++ container.

setup.xml: The application context setup descriptor that describes the configuration and wiring of the modeled GPS application.

Building this example

To build this example, the environment variable POCOCAPSULE_DIR should point to the PocoCapsule/C++ installed directory. Then, this example can be built by simply invoking gmake/make on linux/unix or nmake on windows.

Running this example

· Before starting the application deployment container (i.e. the main executable), make sure the LD_LIBRARY_PATH (on linux and solaris) or the PATH (on windows) environment variable is set correctly to include the ${POCOCAPSULE_DIR}/lib directory.

· start the main executable:

prompt> main 

It will display GPS locations ...

Back to the root page