You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
« Previous
Version 2
Next »
Introduction
On this day we will focus on preparing the initial implementation of our first component. By the end of the day, we expect the groups to:
- Inheritance from IDL interface to be implemented
- Basic implementation of the methods
- Modifying CDB configuration in your test directory
- Exercising your component implementation from objexp and/or a PySimpleClient instance
Guides
As a guide, we're going to show you a very simple component implementation
First we create the directory for the IDL:
> getTemplateForDirectory MODROOT_WS idlHelloComp
> cd idlHelloComp/src
> touch ../idl/HelloComponent.idl
We fill the IDL with the following:
#ifndef _HELLOCOMPONENT_IDL_
#define _HELLOCOMPONENT_IDL_
#pragma prefix "acsws"
#include <acscomponent.idl>
module workshop {
interface HelloComponent : ACS::ACSComponent {
void printHello();
};
};
#endif
We modify the Makefile:
...
IDL_FILES = HelloComponent
HelloComponentStubs_LIBS = acscomponentStubs
...
We then compile and install the IDL definitions:
Configuration
Add the following configuration in the CDB/MACI/Components/Components.xml:
...
<e Name="CPP_HELLO_COMP"
Code="HelloComponentImpl"
Type="IDL:acsws/workshop/HelloComponent:1.0"
Container="bilboContainer"
ImplLang="cpp"/>
<e Name="JAVA_HELLO_COMP"
Code="acsws.workshop.HelloComponentHelper"
Type="IDL:acsws/workshop/HelloComponent:1.0"
Container="frodoContainer"
ImplLang="java"/>
<e Name="PY_HELLO_COMP"
Code="pyHelloComponentImpl"
Type="IDL:acsws/workshop/HelloComponent:1.0"
Container="aragornContainer"
ImplLang="py"/>
...
The above configuration is assuming that we're going to use the default 3 containers.
Implementation
C++
We create the needed directories:
> getTemplateForDirectory MODROOT_WS cppHelloComp
> cd cppHelloComp/src
> touch HelloComponentImpl.cpp
> touch ../include/HelloComponentImpl.h
We modify the Makefile for this component:
...
INCLUDES = HellowComponentImpl.h
...
LIBRARIES = HelloComponentImpl
HelloComponentImpl_OBJECTS = HelloComponentImpl
HelloComponentImpl_LIBS = HelloComponentStubs acscomponent
...
We fill the component code as follows:
#ifndef _HELLO_COMPONENT_IMPL_H
#define _HELLO_COMPONENT_IMPL_H
#ifndef __cplusplus
#error This is a C++ include file and cannot be used from plain C
#endif
//Base component implementation, including container services and component lifecycle infrastructure
#include <acscomponentImpl.h>
//Skeleton interface for server implementation
#include <HelloComponentS.h>
//Error definitions for catching and raising exceptions
class HelloComponentImpl : public virtual acscomponent::ACSComponentImpl, public virtual POA_workshop::HelloComponent {
public:
HelloComponentImpl(const ACE_CString& name, maci::ContainerServices * containerServices);
virtual ~HelloComponentImpl();
void printHello();
};
#endif
#include <HelloComponentImpl.h>
HelloComponentImpl::HelloComponentImpl(const ACE_CString& name, maci::ContainerServices * containerServices) : ACSComponentImpl(name, containerServices) {
}
HelloComponentImpl::~HelloComponentImpl() {
}
void HelloComponentImpl::printHello() {
std::cout << "Just printing 'Hello World!'" << std::endl;
}
/* --------------- [ MACI DLL support functions ] -----------------*/
#include <maciACSComponentDefines.h>
MACI_DLL_SUPPORT_FUNCTIONS(HelloComponentImpl)
/* ----------------------------------------------------------------*/
With this information we are ready to compile our first component that will print the "Hello World" message.