IPC Common C++ API
Contents copied from the project homepage and from powerpoint slides presented at the
Genivi All Members Meeting in Barcelona by Manfred Barthelt, BMW Group, EG-SI Topic Lead
IPC CommonAPI C++
Objective
CommonAPI C++ is an Inter Process Communication (IPC) language binding API for C++, which enables applications to use different IPC middleware as backend without any changes to the application code.
The intention is to make the IPC interface for application development independent from the underlying IPC middleware.
IPC CommonAPI C++ is availlable as open source project on the GENIVI project homepage.
IPC CommonAPI C++
Use Case
CommonAPI C++ can be used to easily adapt and optimize applications to different deployment environments, e.g. to exchange an applications communication from CAN to D-Bus or SomeIP, while retaining the application code as a generic component.
IPC CommonAPI C++
Technologies
The actual CommonAPI C++ interface definitions (C++ header files) can be generated according to abstract interface specifications written in Franca Interface Description Language (Franca-IDL).
Many IPC backends can be implemented for CommonAPI C++, currently a D-Bus based IPC backend is available.
There is eclipse based tooling to accomplish code generation of IPC CommonAPI C++ header files as well as proper D-Bus implementations.
IPC CommonAPI C++
Project Status
- Public project infrastructure launched: http://projects.genivi.org/commonapi/
- API Specification created together with Harman available
- published runtime components and Eclipse based code generator tools as open source (MPL-2.0)
- Accepted for compliance 4.0 (Foton)
- Maintained by BMW development team
- Harman is working on language bindings for DSI and SomeIP
IPC CommonAPI C++
Architecture for D-Bus IPC
IPC CommonAPI C++
Architecture for any IPC
IPC CommonAPI C++
Example: Franca IDLpackage com.harman.test
interface Calculator {
version { major 1 minor 0 }
method add {
in { Int32 value1 Int32 value2 }
out { Int32 summary }
}
}
IPC CommonAPI C++
Example: Client
#include <iostream>
#include <CommonAPI/DBus/DBusRuntime.h>
#include <CommonAPI/Factory.h>
#include <com/harman/test/CalculatorProxy.h>
using namespace std;
int main() {
std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load();
std::shared_ptr<CommonAPI::Factory> factory = runtime->createFactory();
std::string serviceAddress_ = "local:com.harman.test.CalculatorService:com.harman.test.CalculatorInstance";
auto proxy = factory->buildProxy<com::harman::test::CalculatorProxy>(serviceAddress_);
CommonAPI::CallStatus status;
int32_t result;
int32_t s1;
int32_t s2;
while(true) {
cout << "Enter value1: ";
cin >> s1;
cout << "Enter value2: ";
cin >> s2;
proxy->add(s1, s2, status, result);
cout << "Result: " << result << endl;
}
return 0;
}
IPC CommonAPI C++
Example: Service
void CalculatorServiceImpl::add(int32_t value1, int32_t value2, int32_t& summary) {
summary = value1 + value2;
cout << "Adding:" << value1 << " + " << value2 << " = " << summary << endl;
}
int main() {
std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load();
std::shared_ptr<CommonAPI::Factory> factory = runtime->createFactory();
"domain:service:instance"
std::string serviceAddress_ = "local:com.harman.test.CalculatorService:com.harman.test.CalculatorInstance";
auto myStub = std::make_shared<CalculatorServiceImpl>();
bool success = factory->registerService(myStub, serviceAddress_);
if(success) {
cout << "Registered Service" << endl;
// Run forever....
while(true) {
}
}
return 0;
}
IPC CommonAPI C++
Common API
By Torsten Mosis
Common API
- 1,155