Upload
angelo-corsaro
View
1.476
Download
6
Embed Size (px)
DESCRIPTION
This presentation provides an update on the status of the ISO C++ PSM for DDS Standard. The final joint submission should arrive in December 2010.
Citation preview
1
ISO C++ DDS PSM
Angelo CorsaroOMG DDS Co-Chair
Rick WarrenRTI
POC: Angelo Corsaro <[email protected]>
Copyright 2010, PrismTech / RTI
Agenda
- Status Update
- Submission Scope
- API Overview
- Resource Management
- Code Example
- Type Mapping Example
- Next Steps
Copyright 2010, PrismTech / RTI
Status Update
- Tuesday 20th Sept. 2010, after a “conclave” of 4+ hours PrismTech and RTI have resolved all open issues and points of divergence!
- This presentation provides a unified view of what the joint final submission will be.
Copyright 2010, PrismTech / RTI
Agenda
- Status Update
- Submission Scope
- API Overview
- Resource Management
- Code Example
- Type Mapping Example
- Next Steps
Copyright 2010, PrismTech / RTI
Submission Scope
The ISO C++ DDS PSM has the following scope:
- Full API for DCPS v1.2 PIM
- Full API for Extensible Topics
- ISO C++ mapping of DDS Type System (as defined in xtypes)
Copyright 2010, PrismTech / RTI
Agenda
- Status Update
- Submission Scope
- API Overview
- Resource Management
- Code Example
- Type Mapping Example
- Next Steps
Copyright 2010, PrismTech / RTI
Key Highlights
- Simple, safe, efficient, extensible and portable C++ API
- Well defined and safe resource management
- Use of C++ templates to ensure type safety and improve compile time error detection
- Consistent use of Standard C++ types and idioms, such as, std::string, std::vector, iterators, RAII Pattern, etc., throughout the API
Copyright 2010, PrismTech / RTI
API Organization
dds
iddstdds
ANSI/ISO C++ PSM
Vendor Implementation for the DELEGATE layer
DELEGATE
Standard API instantiated from the parametrized API and the vendor implementation of the DELEGATE layer.
DDS type constructors.
Copyright 2010, PrismTech / RTI
Agenda
- Status Update
- Submission Scope
- API Overview
- Resource Management
- Code Example
- Type Mapping Example
- Next Steps
Copyright 2010, PrismTech / RTI
Resource Management- Principles
Safety: Never access uninitialized, freed, or undefined state
Determinism: Applications control when local and remote resources are allocated and released
Expressiveness: Maintain capabilities from PIM
Copyright 2010, PrismTech / RTI
Resource Management
- Expression of principles differ for different kinds of types Reference types: Identity based on reference
• DDS Entities• Wait sets and conditions
Value types: Identity based on state• Entity QoS and QoS policies• Status• Time and duration
Copyright 2010, PrismTech / RTI
Reference Type Usage- Access is through smart pointers, allocated by
factory methods. These: Provide null initialization Throw exception on access to “closed” object May automatically manage resources
- Examples: Null pointer:
• Publisher pub;• if (pub == dds::core::null) { … }
Initialization:• pub = dp.create_publisher();
Copying reference:• Publisher pub2 = pub1; —or— Publisher pub2(pub1);
// 2 references to same object Polymorphism & Down-Casting:
• Entity e = pub; // Publisher pub• Publisher pub = dds::core::polymorphic_cast<Publisher>(e);
Copyright 2010, PrismTech / RTI
Reference Type Mgmt
- Reference types have close() method Disposes object and its contained objects
- Service may automatically close objects no longer in use “May” gives vendors flexibility to balance determinism,
convenience for their users Similar to resource management practice in JMS Common-sense rules:
• If I keep a reference to it, I intend to call it: still in use• If I set a listener, I want it to call me: still in use• If I call retain(): still in use
- Summary: Deterministic way to halt communication, reclaim resources Deterministic way to continue communication, maintain resources Flexibility for vendors
Copyright 2010, PrismTech / RTI
Agenda
- Status Update
- Submission Scope
- API Overview
- Resource Management
- Type Mapping Example
- Code Example
- Next Steps
Copyright 2010, PrismTech / RTI
DDS Types Mapping
- The ISO C++ API is independent from the specific mapping used for DDS Topic Types, as far as generated types have value semantics The ISO C++ API can be used with the existing
IDL2C++ type mapping, or It can be used with the ISO C++ mapping for
DDS Types as defined in the DDS-XTypes specification
Copyright 2010, PrismTech / RTI
ISO C++ Mapping
-Main Characteristics Use of ISO C++ / StdLib types Full Attribute Encapsulation via accessors Container Safe
- Example... see next slide
Copyright 2010, PrismTech / RTI
DDS Type Mapping
struct TelephoneNumber { string prefix; string number;};
DDS Topic Type ISO C++ Mappingclass TelephoneNumber {
public: TelephoneNumber();
explicit TelephoneNumber(const std::string& prefix,
const std::string& number);
virtual ~TelephoneNumber()public: const std::string& prefix() const; void prefix(const std::string& s); const std::string& number() const; void number(const std::string& s);
// State representation // is implementation dependent};
Copyright 2010, PrismTech / RTI
DDS Type MappingDDS Topic Type
enum MarrialStatus { SINGLE, MARRIED, DIVORCED };
struct Person { long age; //@id(1) wstring name; MarrialStatus married; sequence<TelephoneNumber> tel; sequence<TelefoneNumber, 2> fax; double height; //@optional double weight; //@optional sequence<byte> photo; //@shared };
enum MarrialStatus { SINGLE, MARRIED, DIVORCED };
struct Person { long age; //@id(1) wstring name; MarrialStatus married; sequence<TelephoneNumber> tel; sequence<TelefoneNumber, 2> fax; double height; //@optional double weight; //@optional sequence<byte> photo; //@shared };
Copyright 2010, PrismTech / RTI
DDS Type MappingDDS Topic Type
class Person {public: int32_t age() const; void age(int32_t i);};
ISO C++ Mapping
enum MarrialStatus { SINGLE, MARRIED, DIVORCED };
struct Person { long age; //@id(1) wstring name; MarrialStatus married; sequence<TelephoneNumber> tel; sequence<TelefoneNumber, 2> fax; double height; //@optional double weight; //@optional sequence<byte> photo; //@shared };
Copyright 2010, PrismTech / RTI
DDS Type MappingDDS Topic Type
class Person {public: std::wstring name() const; void name(const std::wstring s);};
ISO C++ Mapping
enum MarrialStatus { SINGLE, MARRIED, DIVORCED };
struct Person { long age; //@id(1) wstring name; MarrialStatus married; sequence<TelephoneNumber> tel; sequence<TelefoneNumber, 2> fax; double height; //@optional double weight; //@optional sequence<byte> photo; //@shared };
Copyright 2010, PrismTech / RTI
DDS Type MappingDDS Topic Type
class Person {public: const std::vector<TelephoneNumber>& tel() const; void tel(const std::vector<TelephoneNumber>& s);};
ISO C++ Mapping
enum MarrialStatus { SINGLE, MARRIED, DIVORCED };
struct Person { long age; //@id(1) wstring name; MarrialStatus married; sequence<TelephoneNumber> tel; sequence<TelefoneNumber, 2> fax; double height; //@optional double weight; //@optional sequence<byte> photo; //@shared };
Copyright 2010, PrismTech / RTI
DDS Type MappingDDS Topic Type
class Person {public: const dds::core::optional<double>& height() const; void height(double d); void height(const dds::core::optional<double>& o);};
ISO C++ Mapping
enum MarrialStatus { SINGLE, MARRIED, DIVORCED };
struct Person { long age; //@id(1) wstring name; MarrialStatus married; sequence<TelephoneNumber> tel; sequence<TelefoneNumber, 2> fax; double height; //@optional double weight; //@optional sequence<byte> photo; //@shared };
Copyright 2010, PrismTech / RTI
DDS Type MappingDDS Topic Type
class Person {public: std::vector<uint8_t>* photo() const; void photo(std::vector<uint8_t>* v);};
ISO C++ Mapping
Copyright 2010, PrismTech / RTI
Agenda
- Status Update
- Submission Scope
- API Overview
- Resource Management
- Type Mapping Example
- Code Example
- Next Steps
Copyright 2010, PrismTech / RTI
Code Example
struct RadarTrack { string id; long x; long y;};
DDS Topic Type
Copyright 2010, PrismTech / RTI
Data Writer
- Create DataWriter
using dds::core; using dds::domain; using dds::pub; using dds::topic;
DomainId id = 0;
DomainParticipant dp = theParticipantFactory().create_participant(id);
Publisher pub = dp.create_publisher();
Topic<RadarTrack> topic = dp.create_topic("RadarTrackTopic");DataWriter<RadarTrack> dw = pub.create_datawriter();RadarTrack t("T101", 100, 200);dw.write(t);
Copyright 2010, PrismTech / RTI
Data Reader
using dds::core; using dds::domain; using dds::pub; using dds::topic;
DomainId id = 0;DomainParticipant dp(id);
DomainParticipant dp = theParticipantFactory().create_participant();
Publisher sub = dp.create_publisher();
Topic<RadarTrack> topic = dp.create_topic("RadarTrackTopic");DataReader<RadarTrack> reader = sub.create_datareader();
Copyright 2010, PrismTech / RTI
Data Reader
- User Provided Container
dr.take(t.begin(), i.begin(), maxsize);
std::vector<RadarTrack> t;std::vector<SampleInfo> i;
RadarTrack at[MSIZE];SampleInfo ai[MSIZE];
dr.take(at, ai, MSIZE);
Copyright 2010, PrismTech / RTI
Data Reader
- Loaned Data
LoanedSamples<RadarTrack> dt = dr.take(); for (LoanedSamples<RadarTrack>::Iterator it = dt.begin(); it != dt.end(); ++it) { const Sample<RadarTrack>& sample = *it; if (sample.is_valid_data()) { const RadarTrack& data = sample.data(); // … } }
Copyright 2010, PrismTech / RTI
Agenda
- Status Update
- Submission Scope
- API Overview
- Resource Management
- Type Mapping Example
- Code Example
- Next Steps
Copyright 2010, PrismTech / RTI
Next Steps
- XTopics API Add support for the XTopics API Complete the Type Mapping to include the full
DDS-XTypes Type System
- Vote for Adoption December Meeting
THANKS
`