Versions Compared

Key

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

...

Code Block
titleMakefile for JavaC++
LIBRARIES:=<LibraryName>
<LibraryName>_OBJECTS = <ListOfObjectsToInclude> #.c and/or .cpp files
<LibraryName>_LIBS = <ListOfLibraryDependencies> #<Interface>Stubs acscomponent ServiceErr <Interface>Err #etc.

...

Code Block
languagecpp
titleC++ Imports
#ifndef _<FILENAME>_H
#define _<FILENAME>_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 <<Interface>S.h>


//Error definitions for catching and raising exceptions
#include <ServiceErr<SYSTEMErr.h>
#include <<Interface>Err.h>

...


#endif

...

Code Block
languagecpp
titleServer Class Definition
//ClassName usually is <Interface> or <Interface>Impl, but can be anything
class <ClassName>: public virtual acscomponent::ACSComponentImpl, public POA_<Module>::<Interface>
{
  public:
    <Interface><ClassName>(const ACE_CString& name, maci::ContainerServices * containerServices);
    ...
};

...

Code Block
languagecpp
titleC++ Component Interaction
//Shared
import#include alma<IDLName>C.<Module>.<Interface>h;
import alma.<Module>.<Interface>Helper;

//By Name
<Module>::<Interface>_var comp = this->getContainerServices()->getComponent<<Module>::<Interface>>("<Name>");

//By Interface. Must be at least one component configured as default!
<Module>::<Interface>_var comp = this->getContainerServices()->getDefaultComponent<<Module>::<Interface>>("IDL:alma/<Module>/<Interface>:1.0");

//Release Components
this->getContainerServices()->releaseComponent(comp->name());

...

Code Block
languagecpp
titleC++ Error Handling
//Shared
#include <<Interface>Err.h>

//For catching exceptions
//Along CORBA calls
catch(<Interface>Err::<ExceptionName>Ex &_ex) { ... }
//Internally in the server... more convenient to edit parameters or log if needed
catch(<Interface>Err::<ExceptionName>ExImpl &_ex) { ... }

//For raising exceptions
//Along CORBA calls
throw <Interface>Err::<ExceptionName>ExImpl(__FILE__, __LINE__, "<CustomMessage>").get<ExceptionName>Ex();
//Internally in the server...
throw <Interface>Err::<ExceptionNanem>ExImpl(__FILE__, __LINE__, "<CustomMessage>");

//For raising exceptions with parameters
<Interface>Err::<ExceptionName>ExImpl err(__FILE__, __LINE__, "<CustomMessage>");
err.set<ParamName>(<Value>);
throw err.get<ExceptionName>Ex();

//For logging an error message from the exceptions
<Interface>Err::<ExceptionName>ExImpl err(__FILE__, __LINE__, "<CustomMessage>");
err.log();
throw err.get<ExceptionName>Ex();

Data types mapping:

To check how data types are mapped between IDL and implementation click here.