SlideShare a Scribd company logo
1 of 35
Download to read offline
Comparing
IDL to C++
with
IDL to C++11
Simplify development of CORBA, DDS, and CCM based
applications
Overview
This presentations gives a comparison between the
IDL to C++ and IDL to C++11 language mappings
It assumes basic understanding of IDL and CORBA
For more information take a look at our TAOX11
website at http://taox11.remedy.nl
2
Introduction
3
Problems with IDL to C++
The IDL to C++ language mapping is from the 90’s
IDL to C++ could not depend on various C++ features
as
• C++ namespace
• C++ exceptions
• Standard Template Library
As a result
• Mapping is hard to use correctly
• Uses its own constructs for everything
4
Why a new language mapping?
IDL to C++ language mapping is impossible to
change because
• Multiple implementations are on the market (open
source and commercial)
• A huge amount of applications have been developed
An updated IDL to C++ language mapping would
force all vendors and users to update their products
The standardization of a new C++ revision in 2011
(ISO/IEC 14882:2011, called C++11) gives the
opportunity to define a new language mapping
• C++11 features are not backward compatible with
C++03 or C++99
• A new C++11 mapping leaves the existing mapping
intact
5
Goals
Simplify mapping for C++
Make use of the new C++11 features to
• Reduce amount of application code
• Reduce amount of possible errors made
• Gain runtime performance
• Speedup development and testing
Faster time to market
Reduced costs
Reduced training time
6
OMG Specification
IDL to C++11 v1.2 available from the OMG website
as formal/2015-08-01
Revision Task Force (RTF) is active to work on
issues reported
7
IDL Constructs
8
Modules
An IDL module maps to a C++ namespace with the
same name, same for both mappings
module M
{
// definitions
};
module A
{
module B
{
// definitions
};
};
IDL C++/C++11
namespace M
{
// definitions
};
namespace A
{
namespace B
{
// definitions
};
};
9 Copyright © Remedy IT
Basic types
IDL C++ C++11 C++11 Default value
short CORBA::Short int16_t 0
long CORBA::Long int32_t 0
long long CORBA::LongLong int64_t 0
unsigned short CORBA::UShort uint16_t 0
unsigned long CORBA::ULong uint32_t 0
unsigned long long CORBA::ULongLong uint64_t 0
float CORBA::Float float 0.0
double CORBA::Double double 0.0
long double CORBA::LongDouble long double 0.0
char CORBA::Char char 0
wchar CORBA::WChar wchar_t 0
boolean CORBA::Boolean bool false
octet CORBA::Octet uint8_t 0
10
Constants
const string name = "testing";
interface A
{
const float pi = 3.14159;
};
const char *const name = "testing";
class A
{
public:
static const CORBA::Float pi;
};
C++ C++11
const std::string name {"testing"};
class A
{
public:
static constexpr float pi {3.14159F};
};
11 Copyright © Remedy IT
String types
string name;
wstring w_name;
CORBA::String_var name;
CORBA::WString_var w_name;
name = CORBA::string_dup (“Hello”);
std::cout << name.in () << std::endl;
C++ C++11
std::string name {“Hello”};
std::wstring w_name;
std::cout << name << std::endl;
12 Copyright © Remedy IT
Enum
enum Color {
red,
green,
blue
};
enum Color
{
red,
green,
blue
};
Color mycolor
mycolor = red;
if (mycolor == red)
{
std::cout << “Correct color”;
}
C++ C++11
enum class Color : uint32_t
{
red,
green,
blue
};
Color mycolor {Color::red};
if (mycolor == Color::red)
{
std::cout << “Correct color”;
}
13 Copyright © Remedy IT
Sequence
typedef sequence<long> LongSeq;
LongSeq mysequence;
// Add an element to the vector
Mysequence.length (1)
Mysequence[1] = 5;
for (CORBA::ULong i = 0; I <
mysequence.length(); i++)
{
std::cout << mysequence[i] << “;” <<
std::end;
}
C++ C++11
LongSeq mysequence;
// Add an element to the vector
mysequence.push_back (5);
// Dump using C++11 range based for loop
for (const int32_t& e : mysequence)
{
std::cout << e << “;” << std::end;
}
14 Copyright © Remedy IT
Struct (1)
struct Variable {
string name;
};
struct Variable {
string name;
};
C++ C++11
class Variable final
{
public:
Variable ();
~Variable ();
Variable (const Variable&);
Variable (Variable&&);
Variable& operator= (const Variable& x);
Variable& operator= (Variable&& x);
explicit Variable (std::string name);
void name (const std::string& _name);
void name (std::string&& _name);
const std::string& name () const;
std::string& name ();
};
namespace std
{
template <>
void swap (Variable& m1, Variable& m2);
};
15 Copyright © Remedy IT
Struct (2)
Variable v;
Variable v2 (“Hello”);
CORBA::String_var myname =
CORBA::String_dup (“Hello”);
// Set a struct member
v.name = CORBA::String_dup (myname.in ());
// Get a struct member
CORBA::String_var l_name =
CORBA::String_dup (v.name.in ());
std::cout << “name” << l_name.in () <<
std::endl;
if (strcmp (v.in (), v2.in () != 0)
{
std::cerr << “names are different”
<<std::endl;
}
C++ C++11
Variable v;
Variable v2 (“Hello”);
std::string myname {“Hello”};
// Set a struct member
v.name (myname);
// Get a struct member
std::cout << “name” << v.name () <<
std::endl;
if (v != v2)
{
std::cerr << “names are different”
<<std::endl;
}
16 Copyright © Remedy IT
C++11 Reference types (1)
An IDL interface maps to so called reference types
Reference types are reference counted, for example
given type A
• Strong reference type behaves like
std::shared_ptr and is available as
IDL::traits<A>::ref_type
• Weak reference type behaves like std::weak_ptr
and is available as
IDL::traits<A>::weak_ref_type
A nil reference type is represented as nullptr
Invoking an operation on a nil reference results in a
INV_OBJREF exception
18
C++11 Reference types (2)
Given IDL type A the mapping delivers
IDL::traits<A> with type traits
interface A
{
// definitions
};
IDL C++11
// Obtain a reference
IDL::traits<A>::ref_type a = // .. obtain a
// reference
// Obtain a weak reference
IDL::traits<A>::weak_ref_type w =
a.weak_reference();
// Obtain a strong reference from a weak one
IDL::traits<A>::ref_type p = w.lock ();
if (a == nullptr) // Legal comparisons
if (a != nullptr ) // legal comparison
if (a) // legal usage, true if a != nullptr
if (!a) // legal usage, true if a == nullptr
if (a == 0) // illegal, results in a compile
// error
delete a; // illegal, results in a compile error
19 Copyright © Remedy IT
C++11 Reference types (2)
Reference types can only be constructed using
CORBA::make_reference
interface A
{
// definitions
};
IDL C++11
// Servant implementation class
class A_impl :
CORBA::servant_traits<A>::base_type
{
}
// Create a servant reference using
// make_reference
CORBA::servant_traits<A>::ref_type a_ref =
CORBA::make_reference<A_impl> ();
// We could use new, but the resulting
// pointer can’t be used for making any
// CORBA call because the pointer can’t be
// used to construct a reference type which
// is the only thing the API accepts
A_impl* p = new ACE_impl ();
// Or we can obtain a reference from another
// method
IDL::traits<A>::ref_type = foo->get_a ();
20 Copyright © Remedy IT
C++11 Reference types (3)
Widening and narrowing references
interface A
{
// definitions
};
interface B : A
{
// definitions
};
IDL C++11
IDL::traits<B>::ref_type bp = ...
// Implicit widening
IDL::traits<A>::ref_type ap = bp;
// Implicit widening
IDL::traits<Object>::ref_type objp = bp;
// Implicit widening
objp = ap;
// Explicit narrowing
bp = IDL::traits<B>::narrow (ap)
21 Copyright © Remedy IT
Reference types
Using a reference type
class B {
public:
// Store the reference in a member
B (A_ptr a) : a_(A::_duplicate (a)) {}
// Return a reference
A_ptr get_A () { return A::_duplicate
(a_.in ());
private:
A_var a_;
};
22
C++ C++11
class B {
public:
// Store the reference in a member
B (IDL::ref_type<A> a) : a_ (a)
// Return a reference
IDL::ref_type<A> get_A() { return a_;}
private:
IDL::ref_type<A> a_;
};
Copyright © Remedy IT
Argument passing
Simplified rules for argument passing compared to
IDL to C++
No need for new/delete when passing arguments
The C++11 move semantics can be used to prevent
copying of data
Given an argument of A of type P:
• In: for all primitive types, enums, and reference
types, the argument is passed as P. For all other
types, the argument is passed as const P&
• Inout: passed as P&
• Out: passed as P&
• Return type: returned as P
23
Interfaces implementation
Given a local interface A the implementation has to
be derived from IDL::traits<A>::base_type
Given a regular interface A the CORBA servant
implementation has to be derived from
CORBA::servant_traits<A>::base_type
In both cases a client reference is available as
IDL::traits<A>::ref_type
24
Implementing a servant
Implement a CORBA servant for interface A
class A_impl : public virtual
POA::A
{
};
25
C++ C++11
class A_impl : public virtual
CORBA::servant_traits<A>::ref_type
{
};
Copyright © Remedy IT
C++11 Example application
26
CORBA Hello world
interface Hello
{
/// Return a simple string
string get_string ();
/// A method to shutdown the server
oneway void shutdown ();
};
IDL
27
Copyright © Remedy IT
Copyright © Remedy IT
CORBA client
int main(int argc, char* argv[])
{
try
{
// Obtain the ORB
IDL::traits<CORBA::ORB>::ref_type orb = CORBA::ORB_init (argc, argv);
// Create the object reference
IDL::traits<CORBA::Object>::ref_type obj = orb->string_to_object ("file://test.ior");
// Narrow it to the needed type
IDL::traits<Hello>::ref_type hello = IDL::traits<Hello>::narrow (obj);
// Invoke a method, invoking on a nil reference will result in an exception
std::cout << "hello->get_string () returned " << hello->get_string () << std::endl;
// Shutdown the server
hello->shutdown ();
// Cleanup our ORB
orb->destroy ();
}
catch (const std::exception& e)
{
// All exceptions are derived from std::exception
std::cerr << "exception caught: " << e.what () << std::endl;
}
return 0;
}
28
CORBA servant
C++11 CORBA servant for type T must be derived
from CORBA::servant_traits<T>::base_type
class Hello final : public virtual CORBA::servant_traits<Hello>::base_type
{
public:
// Constructor
Hello (IDL::traits<CORBA::ORB>::ref_type orb) : orb_ (orb) {}
// Destructor
virtual ~Hello () {}
// Implement pure virtual methods from the base_type
virtual std::string get_string () override
{
return “Hello!”;
}
virtual void shutdown () override
{
this->orb_->shutdown (false);
}
private:
// Use an ORB reference to shutdown the application.
IDL::traits<CORBA::ORB>::ref_type orb_;
};
29
CORBA server (1)
int main(int argc, char* argv[])
{
try
{
// Obtain our ORB
IDL::traits<CORBA::ORB>::ref_type orb = CORBA::ORB_init (argc, argv);
// Obtain our POA and POAManager
IDL::traits<CORBA::Object>::ref_type obj = orb->resolve_initial_references ("RootPOA");
IDL::traits<PortableServer::POA>::ref_type root_poa =
IDL::traits<PortableServer::POA>::narrow (obj);
IDL::traits<PortableServer::POAManager>::ref_type poaman = root_poa->the_POAManager ();
// Create the servant
CORBA::servant_traits<Hello>::ref_type hello_impl =
CORBA::make_reference<Hello> (orb);
// Activate the servant as CORBA object
PortableServer::ObjectId id = root_poa->activate_object (hello_impl);
IDL::traits<CORBA::Object>::ref_type hello_obj = root_poa->id_to_reference (id);
IDL::traits<Hello>::ref_type hello =
IDL::traits<Hello>::narrow (hello_obj);
// Put the IOR on disk
std::string ior = orb->object_to_string (hello);
std::ofstream fos("test.ior");
fos << ior;
fos.close ();
30
CORBA server (2)
// Activate our POA
poaman->activate ();
// And run the ORB, this method will return at the moment the ORB has been shutdown
orb->run ();
// Cleanup our resources
root_poa->destroy (true, true);
orb->destroy ();
}
catch (const std::exception& e)
{
// Any exception will be caught here
std::cerr << "exception caught: " << e.what () << std::endl;
}
return 0;
}
31
Tips & Tricks
Don’t use new/delete
Use pass by value together with C++11 move
semantics
32
Conclusion
C++11 simplifies CORBA programming
The combination of reference counting and C++11
move semantics make the code much safer and
secure
Application code is much smaller and easier to read
33
TAOX11
Commercial CORBA implementation from Remedy IT
Compliant with IDL to C++11 v1.2
IDL compiler with front end supporting IDL2, IDL3,
and IDL3+
Free evaluation versions available from
http://swsupport.remedy.nl!
More details at http://taox11.remedy.nl
34
Want to know more?
Look at TAOX11 at http://taox11.remedy.nl
Check the Remedy IT provided examples at
https://github.com/RemedyIT/idl2cpp11
Contact us, see http://www.remedy.nl
35
Contact
36
Remedy IT
Postbus 81
6930 AB Westervoort
The Netherlands
tel.: +31(0)88 – 053 0000
e-mail: sales@remedy.nl
website: www.remedy.nl
Twitter: @RemedyIT
Slideshare: RemedyIT
Subscribe to our mailing list

More Related Content

What's hot

AXCIOMA, the internals, the component framework for distributed, real-time, a...
AXCIOMA, the internals, the component framework for distributed, real-time, a...AXCIOMA, the internals, the component framework for distributed, real-time, a...
AXCIOMA, the internals, the component framework for distributed, real-time, a...Remedy IT
 
Compiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler ConstructionCompiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler ConstructionEelco Visser
 
05 rpc-case studies
05 rpc-case studies05 rpc-case studies
05 rpc-case studieshushu
 
Boogie 2011 Hi-Lite
Boogie 2011 Hi-LiteBoogie 2011 Hi-Lite
Boogie 2011 Hi-LiteAdaCore
 
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Maarten Balliauw
 
Component Object Model (COM, DCOM, COM+)
Component Object Model (COM, DCOM, COM+)Component Object Model (COM, DCOM, COM+)
Component Object Model (COM, DCOM, COM+)Peter R. Egli
 
Common Object Request Broker Architecture - CORBA
Common Object Request Broker Architecture - CORBACommon Object Request Broker Architecture - CORBA
Common Object Request Broker Architecture - CORBAPeter R. Egli
 
IDL to C++11 OMG RTWS presentations
IDL to C++11 OMG RTWS presentationsIDL to C++11 OMG RTWS presentations
IDL to C++11 OMG RTWS presentationsRemedy IT
 
Net serialization
Net serializationNet serialization
Net serializationGreg Sohl
 
CORBA Component Model
CORBA Component Model CORBA Component Model
CORBA Component Model Elham Hormozi
 
Component object model and
Component object model andComponent object model and
Component object model andSaransh Garg
 
RMI and CORBA Why both are valuable tools
RMI and CORBA Why both are valuable toolsRMI and CORBA Why both are valuable tools
RMI and CORBA Why both are valuable toolselliando dias
 
Android coding guide lines
Android coding guide linesAndroid coding guide lines
Android coding guide lineslokeshG38
 

What's hot (20)

AXCIOMA, the internals, the component framework for distributed, real-time, a...
AXCIOMA, the internals, the component framework for distributed, real-time, a...AXCIOMA, the internals, the component framework for distributed, real-time, a...
AXCIOMA, the internals, the component framework for distributed, real-time, a...
 
Compiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler ConstructionCompiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler Construction
 
Objc
ObjcObjc
Objc
 
05 rpc-case studies
05 rpc-case studies05 rpc-case studies
05 rpc-case studies
 
COM
COMCOM
COM
 
Boogie 2011 Hi-Lite
Boogie 2011 Hi-LiteBoogie 2011 Hi-Lite
Boogie 2011 Hi-Lite
 
COM Introduction
COM IntroductionCOM Introduction
COM Introduction
 
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
 
Component Object Model (COM, DCOM, COM+)
Component Object Model (COM, DCOM, COM+)Component Object Model (COM, DCOM, COM+)
Component Object Model (COM, DCOM, COM+)
 
C O R B A Unit 4
C O R B A    Unit 4C O R B A    Unit 4
C O R B A Unit 4
 
Common Object Request Broker Architecture - CORBA
Common Object Request Broker Architecture - CORBACommon Object Request Broker Architecture - CORBA
Common Object Request Broker Architecture - CORBA
 
Corba model ppt
Corba model pptCorba model ppt
Corba model ppt
 
IDL to C++11 OMG RTWS presentations
IDL to C++11 OMG RTWS presentationsIDL to C++11 OMG RTWS presentations
IDL to C++11 OMG RTWS presentations
 
Presentation On Com Dcom
Presentation On Com DcomPresentation On Com Dcom
Presentation On Com Dcom
 
Net serialization
Net serializationNet serialization
Net serialization
 
Corba by Example
Corba by ExampleCorba by Example
Corba by Example
 
CORBA Component Model
CORBA Component Model CORBA Component Model
CORBA Component Model
 
Component object model and
Component object model andComponent object model and
Component object model and
 
RMI and CORBA Why both are valuable tools
RMI and CORBA Why both are valuable toolsRMI and CORBA Why both are valuable tools
RMI and CORBA Why both are valuable tools
 
Android coding guide lines
Android coding guide linesAndroid coding guide lines
Android coding guide lines
 

Similar to Comparing IDL to C++ with IDL to C++11

CORBA Programming with TAOX11/C++11 tutorial
CORBA Programming with TAOX11/C++11 tutorialCORBA Programming with TAOX11/C++11 tutorial
CORBA Programming with TAOX11/C++11 tutorialRemedy IT
 
AMI4CCM_IDL2CPP
AMI4CCM_IDL2CPPAMI4CCM_IDL2CPP
AMI4CCM_IDL2CPPRemedy IT
 
Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)Geeks Anonymes
 
Strategy and best practice for modern RPG
Strategy and best practice for modern RPGStrategy and best practice for modern RPG
Strategy and best practice for modern RPGAlemanalfredo
 
Gentle introduction to modern C++
Gentle introduction to modern C++Gentle introduction to modern C++
Gentle introduction to modern C++Mihai Todor
 
AMI4CCM, custom DDS connectors, and IDL to C++11
AMI4CCM, custom DDS connectors, and IDL to C++11AMI4CCM, custom DDS connectors, and IDL to C++11
AMI4CCM, custom DDS connectors, and IDL to C++11Remedy IT
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 FeaturesJan Rüegg
 
IDL to C++11 revised submission presentation
IDL to C++11 revised submission presentationIDL to C++11 revised submission presentation
IDL to C++11 revised submission presentationRemedy IT
 
C++ Interface Versioning
C++ Interface VersioningC++ Interface Versioning
C++ Interface VersioningSkills Matter
 
Report on c and c++
Report on c and c++Report on c and c++
Report on c and c++oggyrao
 
Gude for C++11 in Apache Traffic Server
Gude for C++11 in Apache Traffic ServerGude for C++11 in Apache Traffic Server
Gude for C++11 in Apache Traffic ServerApache Traffic Server
 
Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1Ali Aminian
 
Unix system programming
Unix system programmingUnix system programming
Unix system programmingSyed Mustafa
 

Similar to Comparing IDL to C++ with IDL to C++11 (20)

CORBA Programming with TAOX11/C++11 tutorial
CORBA Programming with TAOX11/C++11 tutorialCORBA Programming with TAOX11/C++11 tutorial
CORBA Programming with TAOX11/C++11 tutorial
 
AMI4CCM_IDL2CPP
AMI4CCM_IDL2CPPAMI4CCM_IDL2CPP
AMI4CCM_IDL2CPP
 
Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)
 
Intro to c++
Intro to c++Intro to c++
Intro to c++
 
DCOM Comparison
DCOM ComparisonDCOM Comparison
DCOM Comparison
 
Strategy and best practice for modern RPG
Strategy and best practice for modern RPGStrategy and best practice for modern RPG
Strategy and best practice for modern RPG
 
Gentle introduction to modern C++
Gentle introduction to modern C++Gentle introduction to modern C++
Gentle introduction to modern C++
 
AMI4CCM, custom DDS connectors, and IDL to C++11
AMI4CCM, custom DDS connectors, and IDL to C++11AMI4CCM, custom DDS connectors, and IDL to C++11
AMI4CCM, custom DDS connectors, and IDL to C++11
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 Features
 
IDL to C++11 revised submission presentation
IDL to C++11 revised submission presentationIDL to C++11 revised submission presentation
IDL to C++11 revised submission presentation
 
C++ Interface Versioning
C++ Interface VersioningC++ Interface Versioning
C++ Interface Versioning
 
Report on c and c++
Report on c and c++Report on c and c++
Report on c and c++
 
Chapter 17 corba
Chapter 17 corbaChapter 17 corba
Chapter 17 corba
 
Gude for C++11 in Apache Traffic Server
Gude for C++11 in Apache Traffic ServerGude for C++11 in Apache Traffic Server
Gude for C++11 in Apache Traffic Server
 
Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1
 
Rcpp
RcppRcpp
Rcpp
 
C LANGUAGE NOTES
C LANGUAGE NOTESC LANGUAGE NOTES
C LANGUAGE NOTES
 
Unix system programming
Unix system programmingUnix system programming
Unix system programming
 
Oops presentation
Oops presentationOops presentation
Oops presentation
 
C++ Constructs.pptx
C++ Constructs.pptxC++ Constructs.pptx
C++ Constructs.pptx
 

More from Remedy IT

AXCIOMA, the component framework for distributed, real-time and embedded systems
AXCIOMA, the component framework for distributed, real-time and embedded systemsAXCIOMA, the component framework for distributed, real-time and embedded systems
AXCIOMA, the component framework for distributed, real-time and embedded systemsRemedy IT
 
Remedy IT Company presentation
Remedy IT Company presentationRemedy IT Company presentation
Remedy IT Company presentationRemedy IT
 
Comparing IDL to C++ with IDL to C++11
Comparing IDL to C++ with IDL to C++11Comparing IDL to C++ with IDL to C++11
Comparing IDL to C++ with IDL to C++11Remedy IT
 
Modernizing SCA through new Object Management Group (OMG) standards
Modernizing SCA through new Object Management Group (OMG) standardsModernizing SCA through new Object Management Group (OMG) standards
Modernizing SCA through new Object Management Group (OMG) standardsRemedy IT
 
ACE/TAO/CIAO/DAnCE Maintenance overview
ACE/TAO/CIAO/DAnCE Maintenance overviewACE/TAO/CIAO/DAnCE Maintenance overview
ACE/TAO/CIAO/DAnCE Maintenance overviewRemedy IT
 
Remedy IT Revised Submission Presentation for the Unified Component Model (UC...
Remedy IT Revised Submission Presentation for the Unified Component Model (UC...Remedy IT Revised Submission Presentation for the Unified Component Model (UC...
Remedy IT Revised Submission Presentation for the Unified Component Model (UC...Remedy IT
 
Revised submission for Unified Component Model (UCM) for Distributed, Real-Ti...
Revised submission for Unified Component Model (UCM) for Distributed, Real-Ti...Revised submission for Unified Component Model (UCM) for Distributed, Real-Ti...
Revised submission for Unified Component Model (UCM) for Distributed, Real-Ti...Remedy IT
 
Component Based DDS with C++11 and R2DDS
Component Based DDS with C++11 and R2DDSComponent Based DDS with C++11 and R2DDS
Component Based DDS with C++11 and R2DDSRemedy IT
 
AXCIOMA, the component framework for distributed, real-time and embedded systems
AXCIOMA, the component framework for distributed, real-time and embedded systemsAXCIOMA, the component framework for distributed, real-time and embedded systems
AXCIOMA, the component framework for distributed, real-time and embedded systemsRemedy IT
 
Component Technologies for Fractionated Satellites
Component Technologies for Fractionated SatellitesComponent Technologies for Fractionated Satellites
Component Technologies for Fractionated SatellitesRemedy IT
 
UCM Initial Submission presentation
UCM Initial Submission presentationUCM Initial Submission presentation
UCM Initial Submission presentationRemedy IT
 
Remedy IT Initial Submission for the Unified Component Model (UCM) for Distri...
Remedy IT Initial Submission for the Unified Component Model (UCM) for Distri...Remedy IT Initial Submission for the Unified Component Model (UCM) for Distri...
Remedy IT Initial Submission for the Unified Component Model (UCM) for Distri...Remedy IT
 
Unified Component Model for Distributed, Real- Time and Embedded Systems Requ...
Unified Component Model for Distributed, Real- Time and Embedded Systems Requ...Unified Component Model for Distributed, Real- Time and Embedded Systems Requ...
Unified Component Model for Distributed, Real- Time and Embedded Systems Requ...Remedy IT
 
Request For Proposal Unified Component Model for Distributed, Real-Time and E...
Request For Proposal Unified Component Model for Distributed, Real-Time and E...Request For Proposal Unified Component Model for Distributed, Real-Time and E...
Request For Proposal Unified Component Model for Distributed, Real-Time and E...Remedy IT
 
Test What Matters Most
Test What Matters MostTest What Matters Most
Test What Matters MostRemedy IT
 
IDL to C++03 RFC
IDL to C++03 RFCIDL to C++03 RFC
IDL to C++03 RFCRemedy IT
 
Model Driven, Component Based Development for CBDDS and IDL to C++11
Model Driven, Component Based Development for CBDDS and IDL to C++11Model Driven, Component Based Development for CBDDS and IDL to C++11
Model Driven, Component Based Development for CBDDS and IDL to C++11Remedy IT
 
F6COM: A Case Study in Extending Container Services through Connectors
F6COM: A Case Study in Extending Container Services through ConnectorsF6COM: A Case Study in Extending Container Services through Connectors
F6COM: A Case Study in Extending Container Services through ConnectorsRemedy IT
 
Draft Request For Proposal Unified Component Model for Distributed, Real-Time...
Draft Request For Proposal Unified Component Model for Distributed, Real-Time...Draft Request For Proposal Unified Component Model for Distributed, Real-Time...
Draft Request For Proposal Unified Component Model for Distributed, Real-Time...Remedy IT
 
Test What Matters Most
Test What Matters MostTest What Matters Most
Test What Matters MostRemedy IT
 

More from Remedy IT (20)

AXCIOMA, the component framework for distributed, real-time and embedded systems
AXCIOMA, the component framework for distributed, real-time and embedded systemsAXCIOMA, the component framework for distributed, real-time and embedded systems
AXCIOMA, the component framework for distributed, real-time and embedded systems
 
Remedy IT Company presentation
Remedy IT Company presentationRemedy IT Company presentation
Remedy IT Company presentation
 
Comparing IDL to C++ with IDL to C++11
Comparing IDL to C++ with IDL to C++11Comparing IDL to C++ with IDL to C++11
Comparing IDL to C++ with IDL to C++11
 
Modernizing SCA through new Object Management Group (OMG) standards
Modernizing SCA through new Object Management Group (OMG) standardsModernizing SCA through new Object Management Group (OMG) standards
Modernizing SCA through new Object Management Group (OMG) standards
 
ACE/TAO/CIAO/DAnCE Maintenance overview
ACE/TAO/CIAO/DAnCE Maintenance overviewACE/TAO/CIAO/DAnCE Maintenance overview
ACE/TAO/CIAO/DAnCE Maintenance overview
 
Remedy IT Revised Submission Presentation for the Unified Component Model (UC...
Remedy IT Revised Submission Presentation for the Unified Component Model (UC...Remedy IT Revised Submission Presentation for the Unified Component Model (UC...
Remedy IT Revised Submission Presentation for the Unified Component Model (UC...
 
Revised submission for Unified Component Model (UCM) for Distributed, Real-Ti...
Revised submission for Unified Component Model (UCM) for Distributed, Real-Ti...Revised submission for Unified Component Model (UCM) for Distributed, Real-Ti...
Revised submission for Unified Component Model (UCM) for Distributed, Real-Ti...
 
Component Based DDS with C++11 and R2DDS
Component Based DDS with C++11 and R2DDSComponent Based DDS with C++11 and R2DDS
Component Based DDS with C++11 and R2DDS
 
AXCIOMA, the component framework for distributed, real-time and embedded systems
AXCIOMA, the component framework for distributed, real-time and embedded systemsAXCIOMA, the component framework for distributed, real-time and embedded systems
AXCIOMA, the component framework for distributed, real-time and embedded systems
 
Component Technologies for Fractionated Satellites
Component Technologies for Fractionated SatellitesComponent Technologies for Fractionated Satellites
Component Technologies for Fractionated Satellites
 
UCM Initial Submission presentation
UCM Initial Submission presentationUCM Initial Submission presentation
UCM Initial Submission presentation
 
Remedy IT Initial Submission for the Unified Component Model (UCM) for Distri...
Remedy IT Initial Submission for the Unified Component Model (UCM) for Distri...Remedy IT Initial Submission for the Unified Component Model (UCM) for Distri...
Remedy IT Initial Submission for the Unified Component Model (UCM) for Distri...
 
Unified Component Model for Distributed, Real- Time and Embedded Systems Requ...
Unified Component Model for Distributed, Real- Time and Embedded Systems Requ...Unified Component Model for Distributed, Real- Time and Embedded Systems Requ...
Unified Component Model for Distributed, Real- Time and Embedded Systems Requ...
 
Request For Proposal Unified Component Model for Distributed, Real-Time and E...
Request For Proposal Unified Component Model for Distributed, Real-Time and E...Request For Proposal Unified Component Model for Distributed, Real-Time and E...
Request For Proposal Unified Component Model for Distributed, Real-Time and E...
 
Test What Matters Most
Test What Matters MostTest What Matters Most
Test What Matters Most
 
IDL to C++03 RFC
IDL to C++03 RFCIDL to C++03 RFC
IDL to C++03 RFC
 
Model Driven, Component Based Development for CBDDS and IDL to C++11
Model Driven, Component Based Development for CBDDS and IDL to C++11Model Driven, Component Based Development for CBDDS and IDL to C++11
Model Driven, Component Based Development for CBDDS and IDL to C++11
 
F6COM: A Case Study in Extending Container Services through Connectors
F6COM: A Case Study in Extending Container Services through ConnectorsF6COM: A Case Study in Extending Container Services through Connectors
F6COM: A Case Study in Extending Container Services through Connectors
 
Draft Request For Proposal Unified Component Model for Distributed, Real-Time...
Draft Request For Proposal Unified Component Model for Distributed, Real-Time...Draft Request For Proposal Unified Component Model for Distributed, Real-Time...
Draft Request For Proposal Unified Component Model for Distributed, Real-Time...
 
Test What Matters Most
Test What Matters MostTest What Matters Most
Test What Matters Most
 

Recently uploaded

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 

Recently uploaded (20)

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 

Comparing IDL to C++ with IDL to C++11

  • 1. Comparing IDL to C++ with IDL to C++11 Simplify development of CORBA, DDS, and CCM based applications
  • 2. Overview This presentations gives a comparison between the IDL to C++ and IDL to C++11 language mappings It assumes basic understanding of IDL and CORBA For more information take a look at our TAOX11 website at http://taox11.remedy.nl 2
  • 4. Problems with IDL to C++ The IDL to C++ language mapping is from the 90’s IDL to C++ could not depend on various C++ features as • C++ namespace • C++ exceptions • Standard Template Library As a result • Mapping is hard to use correctly • Uses its own constructs for everything 4
  • 5. Why a new language mapping? IDL to C++ language mapping is impossible to change because • Multiple implementations are on the market (open source and commercial) • A huge amount of applications have been developed An updated IDL to C++ language mapping would force all vendors and users to update their products The standardization of a new C++ revision in 2011 (ISO/IEC 14882:2011, called C++11) gives the opportunity to define a new language mapping • C++11 features are not backward compatible with C++03 or C++99 • A new C++11 mapping leaves the existing mapping intact 5
  • 6. Goals Simplify mapping for C++ Make use of the new C++11 features to • Reduce amount of application code • Reduce amount of possible errors made • Gain runtime performance • Speedup development and testing Faster time to market Reduced costs Reduced training time 6
  • 7. OMG Specification IDL to C++11 v1.2 available from the OMG website as formal/2015-08-01 Revision Task Force (RTF) is active to work on issues reported 7
  • 9. Modules An IDL module maps to a C++ namespace with the same name, same for both mappings module M { // definitions }; module A { module B { // definitions }; }; IDL C++/C++11 namespace M { // definitions }; namespace A { namespace B { // definitions }; }; 9 Copyright © Remedy IT
  • 10. Basic types IDL C++ C++11 C++11 Default value short CORBA::Short int16_t 0 long CORBA::Long int32_t 0 long long CORBA::LongLong int64_t 0 unsigned short CORBA::UShort uint16_t 0 unsigned long CORBA::ULong uint32_t 0 unsigned long long CORBA::ULongLong uint64_t 0 float CORBA::Float float 0.0 double CORBA::Double double 0.0 long double CORBA::LongDouble long double 0.0 char CORBA::Char char 0 wchar CORBA::WChar wchar_t 0 boolean CORBA::Boolean bool false octet CORBA::Octet uint8_t 0 10
  • 11. Constants const string name = "testing"; interface A { const float pi = 3.14159; }; const char *const name = "testing"; class A { public: static const CORBA::Float pi; }; C++ C++11 const std::string name {"testing"}; class A { public: static constexpr float pi {3.14159F}; }; 11 Copyright © Remedy IT
  • 12. String types string name; wstring w_name; CORBA::String_var name; CORBA::WString_var w_name; name = CORBA::string_dup (“Hello”); std::cout << name.in () << std::endl; C++ C++11 std::string name {“Hello”}; std::wstring w_name; std::cout << name << std::endl; 12 Copyright © Remedy IT
  • 13. Enum enum Color { red, green, blue }; enum Color { red, green, blue }; Color mycolor mycolor = red; if (mycolor == red) { std::cout << “Correct color”; } C++ C++11 enum class Color : uint32_t { red, green, blue }; Color mycolor {Color::red}; if (mycolor == Color::red) { std::cout << “Correct color”; } 13 Copyright © Remedy IT
  • 14. Sequence typedef sequence<long> LongSeq; LongSeq mysequence; // Add an element to the vector Mysequence.length (1) Mysequence[1] = 5; for (CORBA::ULong i = 0; I < mysequence.length(); i++) { std::cout << mysequence[i] << “;” << std::end; } C++ C++11 LongSeq mysequence; // Add an element to the vector mysequence.push_back (5); // Dump using C++11 range based for loop for (const int32_t& e : mysequence) { std::cout << e << “;” << std::end; } 14 Copyright © Remedy IT
  • 15. Struct (1) struct Variable { string name; }; struct Variable { string name; }; C++ C++11 class Variable final { public: Variable (); ~Variable (); Variable (const Variable&); Variable (Variable&&); Variable& operator= (const Variable& x); Variable& operator= (Variable&& x); explicit Variable (std::string name); void name (const std::string& _name); void name (std::string&& _name); const std::string& name () const; std::string& name (); }; namespace std { template <> void swap (Variable& m1, Variable& m2); }; 15 Copyright © Remedy IT
  • 16. Struct (2) Variable v; Variable v2 (“Hello”); CORBA::String_var myname = CORBA::String_dup (“Hello”); // Set a struct member v.name = CORBA::String_dup (myname.in ()); // Get a struct member CORBA::String_var l_name = CORBA::String_dup (v.name.in ()); std::cout << “name” << l_name.in () << std::endl; if (strcmp (v.in (), v2.in () != 0) { std::cerr << “names are different” <<std::endl; } C++ C++11 Variable v; Variable v2 (“Hello”); std::string myname {“Hello”}; // Set a struct member v.name (myname); // Get a struct member std::cout << “name” << v.name () << std::endl; if (v != v2) { std::cerr << “names are different” <<std::endl; } 16 Copyright © Remedy IT
  • 17. C++11 Reference types (1) An IDL interface maps to so called reference types Reference types are reference counted, for example given type A • Strong reference type behaves like std::shared_ptr and is available as IDL::traits<A>::ref_type • Weak reference type behaves like std::weak_ptr and is available as IDL::traits<A>::weak_ref_type A nil reference type is represented as nullptr Invoking an operation on a nil reference results in a INV_OBJREF exception 18
  • 18. C++11 Reference types (2) Given IDL type A the mapping delivers IDL::traits<A> with type traits interface A { // definitions }; IDL C++11 // Obtain a reference IDL::traits<A>::ref_type a = // .. obtain a // reference // Obtain a weak reference IDL::traits<A>::weak_ref_type w = a.weak_reference(); // Obtain a strong reference from a weak one IDL::traits<A>::ref_type p = w.lock (); if (a == nullptr) // Legal comparisons if (a != nullptr ) // legal comparison if (a) // legal usage, true if a != nullptr if (!a) // legal usage, true if a == nullptr if (a == 0) // illegal, results in a compile // error delete a; // illegal, results in a compile error 19 Copyright © Remedy IT
  • 19. C++11 Reference types (2) Reference types can only be constructed using CORBA::make_reference interface A { // definitions }; IDL C++11 // Servant implementation class class A_impl : CORBA::servant_traits<A>::base_type { } // Create a servant reference using // make_reference CORBA::servant_traits<A>::ref_type a_ref = CORBA::make_reference<A_impl> (); // We could use new, but the resulting // pointer can’t be used for making any // CORBA call because the pointer can’t be // used to construct a reference type which // is the only thing the API accepts A_impl* p = new ACE_impl (); // Or we can obtain a reference from another // method IDL::traits<A>::ref_type = foo->get_a (); 20 Copyright © Remedy IT
  • 20. C++11 Reference types (3) Widening and narrowing references interface A { // definitions }; interface B : A { // definitions }; IDL C++11 IDL::traits<B>::ref_type bp = ... // Implicit widening IDL::traits<A>::ref_type ap = bp; // Implicit widening IDL::traits<Object>::ref_type objp = bp; // Implicit widening objp = ap; // Explicit narrowing bp = IDL::traits<B>::narrow (ap) 21 Copyright © Remedy IT
  • 21. Reference types Using a reference type class B { public: // Store the reference in a member B (A_ptr a) : a_(A::_duplicate (a)) {} // Return a reference A_ptr get_A () { return A::_duplicate (a_.in ()); private: A_var a_; }; 22 C++ C++11 class B { public: // Store the reference in a member B (IDL::ref_type<A> a) : a_ (a) // Return a reference IDL::ref_type<A> get_A() { return a_;} private: IDL::ref_type<A> a_; }; Copyright © Remedy IT
  • 22. Argument passing Simplified rules for argument passing compared to IDL to C++ No need for new/delete when passing arguments The C++11 move semantics can be used to prevent copying of data Given an argument of A of type P: • In: for all primitive types, enums, and reference types, the argument is passed as P. For all other types, the argument is passed as const P& • Inout: passed as P& • Out: passed as P& • Return type: returned as P 23
  • 23. Interfaces implementation Given a local interface A the implementation has to be derived from IDL::traits<A>::base_type Given a regular interface A the CORBA servant implementation has to be derived from CORBA::servant_traits<A>::base_type In both cases a client reference is available as IDL::traits<A>::ref_type 24
  • 24. Implementing a servant Implement a CORBA servant for interface A class A_impl : public virtual POA::A { }; 25 C++ C++11 class A_impl : public virtual CORBA::servant_traits<A>::ref_type { }; Copyright © Remedy IT
  • 26. CORBA Hello world interface Hello { /// Return a simple string string get_string (); /// A method to shutdown the server oneway void shutdown (); }; IDL 27 Copyright © Remedy IT Copyright © Remedy IT
  • 27. CORBA client int main(int argc, char* argv[]) { try { // Obtain the ORB IDL::traits<CORBA::ORB>::ref_type orb = CORBA::ORB_init (argc, argv); // Create the object reference IDL::traits<CORBA::Object>::ref_type obj = orb->string_to_object ("file://test.ior"); // Narrow it to the needed type IDL::traits<Hello>::ref_type hello = IDL::traits<Hello>::narrow (obj); // Invoke a method, invoking on a nil reference will result in an exception std::cout << "hello->get_string () returned " << hello->get_string () << std::endl; // Shutdown the server hello->shutdown (); // Cleanup our ORB orb->destroy (); } catch (const std::exception& e) { // All exceptions are derived from std::exception std::cerr << "exception caught: " << e.what () << std::endl; } return 0; } 28
  • 28. CORBA servant C++11 CORBA servant for type T must be derived from CORBA::servant_traits<T>::base_type class Hello final : public virtual CORBA::servant_traits<Hello>::base_type { public: // Constructor Hello (IDL::traits<CORBA::ORB>::ref_type orb) : orb_ (orb) {} // Destructor virtual ~Hello () {} // Implement pure virtual methods from the base_type virtual std::string get_string () override { return “Hello!”; } virtual void shutdown () override { this->orb_->shutdown (false); } private: // Use an ORB reference to shutdown the application. IDL::traits<CORBA::ORB>::ref_type orb_; }; 29
  • 29. CORBA server (1) int main(int argc, char* argv[]) { try { // Obtain our ORB IDL::traits<CORBA::ORB>::ref_type orb = CORBA::ORB_init (argc, argv); // Obtain our POA and POAManager IDL::traits<CORBA::Object>::ref_type obj = orb->resolve_initial_references ("RootPOA"); IDL::traits<PortableServer::POA>::ref_type root_poa = IDL::traits<PortableServer::POA>::narrow (obj); IDL::traits<PortableServer::POAManager>::ref_type poaman = root_poa->the_POAManager (); // Create the servant CORBA::servant_traits<Hello>::ref_type hello_impl = CORBA::make_reference<Hello> (orb); // Activate the servant as CORBA object PortableServer::ObjectId id = root_poa->activate_object (hello_impl); IDL::traits<CORBA::Object>::ref_type hello_obj = root_poa->id_to_reference (id); IDL::traits<Hello>::ref_type hello = IDL::traits<Hello>::narrow (hello_obj); // Put the IOR on disk std::string ior = orb->object_to_string (hello); std::ofstream fos("test.ior"); fos << ior; fos.close (); 30
  • 30. CORBA server (2) // Activate our POA poaman->activate (); // And run the ORB, this method will return at the moment the ORB has been shutdown orb->run (); // Cleanup our resources root_poa->destroy (true, true); orb->destroy (); } catch (const std::exception& e) { // Any exception will be caught here std::cerr << "exception caught: " << e.what () << std::endl; } return 0; } 31
  • 31. Tips & Tricks Don’t use new/delete Use pass by value together with C++11 move semantics 32
  • 32. Conclusion C++11 simplifies CORBA programming The combination of reference counting and C++11 move semantics make the code much safer and secure Application code is much smaller and easier to read 33
  • 33. TAOX11 Commercial CORBA implementation from Remedy IT Compliant with IDL to C++11 v1.2 IDL compiler with front end supporting IDL2, IDL3, and IDL3+ Free evaluation versions available from http://swsupport.remedy.nl! More details at http://taox11.remedy.nl 34
  • 34. Want to know more? Look at TAOX11 at http://taox11.remedy.nl Check the Remedy IT provided examples at https://github.com/RemedyIT/idl2cpp11 Contact us, see http://www.remedy.nl 35
  • 35. Contact 36 Remedy IT Postbus 81 6930 AB Westervoort The Netherlands tel.: +31(0)88 – 053 0000 e-mail: sales@remedy.nl website: www.remedy.nl Twitter: @RemedyIT Slideshare: RemedyIT Subscribe to our mailing list