...
Code Block |
---|
language | cpp |
---|
title | idlHelloComp/idl/HelloComponent.idl |
---|
linenumbers | true |
---|
collapse | true |
---|
|
#ifndef _HELLOCOMPONENT_IDL_
#define _HELLOCOMPONENT_IDL_
#pragma prefix "acsws"
#include <acscomponent.idl>
module workshop {
interface HelloComponent : ACS::ACSComponent {
void printHello();
};
};
#endif |
...
Code Block |
---|
> make all install |
Configuration
Add the following configuration in the CDB/MACI/Components/Components.xml:
Code Block |
---|
language | xml |
---|
title | Components.xml |
---|
linenumbers | true |
---|
collapse | true |
---|
|
...
<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:
...
Code Block |
---|
title | cppHelloComponent/src/Makefile |
---|
|
...
INCLUDES = HellowComponentImpl.h
...
LIBRARIES = HelloComponentImpl
HelloComponentImpl_OBJECTS = HelloComponentImpl
HelloComponentImpl_LIBS = HelloComponentStubs acscomponent
... |
We fill the component code as follows:
Code Block |
---|
language | cpp |
---|
title | cppHelloComponent/include/HelloComponentImpl.h |
---|
linenumbers | true |
---|
collapse | true |
---|
|
#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 |
Code Block |
---|
language | cpp |
---|
title | cppHelloComponent/src/HelloComponentImpl.cpp |
---|
linenumbers | true |
---|
collapse | true |
---|
|
#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.