180 likes | 391 Views
ACS Training. Developing a C++ Component. Getting Started with ACS Course and ACS Example. At the console, type: cvs co ACS/LGPL/CommonSoftware/acscourse This gives you the latest version of the ACS Course module. And cvs co ACS/LGPL/CommonSoftware/acsexample
E N D
ACS Training Developing a C++ Component
Getting Started with ACS Course and ACS Example At the console, type: cvs co ACS/LGPL/CommonSoftware/acscourse This gives you the latest version of the ACS Course module. And cvs co ACS/LGPL/CommonSoftware/acsexample This gives you the latest version of the ACS Example module containing C++ examples for ACS. ACS Training
What files need to be created? • IDL (Interface Definition Language) File(s) • Specifies object methods that are useful to clients. • Specifies object members that can be manipulated by clients. • Good place to describe data structures that will be used by multiple programming languages. ACS Training
What files needs to be created? (continued) • C++ Implementation Files • Implementation of the IDL to C++ CORBA mapping. • What actually ends up invoking clients calls. • Normally consists of one header file and one implementation file. ACS Training
What files needs to be created(continued)? • Components.xml (deployment information) • Defines the name, IDL type, implementation code (shared library in C++), and Container where the Component instance will run. ACS Training
Sample IDL Interface ACS/LGPL/CommonSoftware/acscourse/ws/idl/acscourseMount.idl #ifndef _ACSCOURSE_MOUNT_IDL_ #define _ACSCOURSE_MOUNT_IDL_ #include <acscomponent.idl> #pragma prefix "alma" module ACSCOURSE_MOUNT { interface Mount1 : ACS::ACSComponent { voidobjfix (in doubleaz, in doubleelev) raises (ACSErrTypeACSCourse::TargetNotFoundEx); }; }; #endif ACS Training
High-level ACS C++ Concepts • For each method in the IDL, there exists exactly one C++ method of the same name. • For every IDL attribute, there is one method of the same name used to access that IDL attribute and one C++ member variable (which can be named almost anything). ACS Training
Sample C++ Implementation Header #ifndef acscourseMount1Impl_h #define acscourseMount1Impl_h #ifndef __cplusplus #error This is a C++ include file and cannot be used from plain C #endif #include <acscomponentImpl.h> #include <acscourseMountS.h> using namespace acscomponent; class Mount1Impl: public virtual ACSComponentImpl, public virtual POA_ACSCOURSE_MOUNT::Mount1 { public: Mount1Impl(const ACE_CString &name, maci::ContainerServices *containerServices); virtual ~Mount1Impl(); ACS Training
Sample C++ Implementation Header (continued) virtual void objfix (CORBA::Double az, CORBA::Double elev) throw (CORBA::SystemException); private: void operator=(const Mount1Impl&); }; #endif /*!acscourseMount1Impl_H*/ ACS Training
Other C++ Headers acsexmpl/ws/include/*Impl.h ACS Training
Sample C++ Implementation #include <acscourseMount1Impl.h> #include <iostream> using namespace std; Mount1Impl::Mount1Impl(const ACE_CString &name, maci::ContainerServices *containerServices) : acscomponent::ACSComponentImpl(name, containerServices) { // ACS_TRACE is used for debugging purposes ACS_TRACE("::Mount1Impl::Mount1Impl"); } Mount1Impl::~Mount1Impl() { ACS_TRACE("::Mount1Impl::~Mount1Impl"); ACS_DEBUG_PARAM("::Mount1Impl::~Mount1Impl", "Destroying %s...", name()); } ACS Training
Sample C++ Implementation(continued) void Mount1Impl::objfix (CORBA::Double az, CORBA::Double elev) throw (CORBA::SystemException) { cout << "Received objfix command. Az: " << az << " El: " << elev << endl; } #include <maciACSComponentDefines.h> MACI_DLL_SUPPORT_FUNCTIONS(Mount1Impl) /*___oOo___*/ ACS Training
Other C++ Implementations acsexmpl/ws/src/*Impl.cpp ACS Training
CDB/MACI/COBs/COBs.xml <?xml version="1.0" encoding="utf-8"?> <Components xmlns="urn:schemas-cosylab-com:Components:1.0" xmlns:cdb="urn:schemas-cosylab-com:CDB:1.0" xmlns:baci="urn:schemas-cosylab-com:BACI:1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <_ Name="MOUNT1_01" Code="acscourseMount1Impl" Type="IDL:alma/ACSCOURSE_MOUNT/Mount1:1.0“ Container=“bilboContainer”> </Components> ACS Training
Other Files involving the CDB acsexmpl/ws/test/CDB/* ACS Training
C++ Implementation Diagram IDL C++ Stub C++ Skeleton Implementation “DLL” Library (*.h, *.cpp) ACS ACS Training
Questions about Component’s implementation in CPP??? ACS Training
Demo(s)??? ACS Training