Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Create component

Code Block
languagebash
cd ~/workspace
getTemplateForDirectory MODROOT_WS cppHelloComp
cd cppHelloComp/src
touch HelloComponentImpl.cpp
touch ../include/HelloComponentImpl.h
vim Makefile

We modify the Makefile for this component:

Code Block
languagebash
titlecppHelloComp/src/Makefile
...
INCLUDES = HelloComponentImpl.h
...
LIBRARIES = HelloComponentImpl
HelloComponentImpl_OBJECTS = HelloComponentImpl
HelloComponentImpl_LIBS = HelloComponentStubs acscomponent
...

We fill the component code as follows:

Code Block
languagebash
vim ../include/HelloComponentImpl.h
Code Block
languagepy
titlecppHelloComp/include/HelloComponentImpl.h
#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();
    char* printHello();
};
 
#endif

Compile component

Code Block
languagebash
export LD_LIBRARY_PATH=$INTROOT/lib:$LD_LIBRARY_PATH
make all install