DDS is a very powerful technology built around a few simple and orthogonal concepts. If you understand the core concepts then you can really quickly get up to speed and start exploiting all of its power. On the other hand, if you haven’t grasped the key abstractions you might not be able to exploit all the benefits that DDS can bring.
This presentation provides you with an introduction to the core DDS concepts and illustrates how to program DDS applications. The new C++ and Java API will be explained and used throughout the webcast for coding examples thus giving you a chance to learn the new API from one of the main authors!
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Getting Started in DDS with C++ and Java
1. Angelo Corsaro, Ph.D.
Chief Technology Officer
PrismTech
OMG DDS SIG Co-Chair
angelo.corsaro@prismtech.com
OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Getting Started with DDS
For C++ and Java Programmers
1
3. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
The OMG DDS
The OMG DDS Standard
‣ Introduced in 2004 to address the Data
distribution challenges typical of Defense
and Aerospace Mission Critical Applications
‣ Key requirements for the standard were high
performance and scalability from embedded
to ultra-large-scale deployments
‣ Today recommended by key administrations
worldwide and widely adopted well beyond
Aerospace and Defense in domains, such as,
Automated Trading, Simulations, SCADA,
Telemetry, etc.
3
4. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
DDS Recommendations
Increasingly Mandated/Recommended by Administrations
‣ US Navy: Open Architecture
‣ DISR/DISA: Net-centric Systems
‣ EuroControl: Air Traffic Control Center Operational
Interoperability
‣ QinetiQ & MILVA: Recommending DDS for Vehicles
Electronic Architecture
! The infrastructure evolution cycle is churning…
– New -> Emerging -> Standard -> Commodity
– Middleware is emerging as OS declines
! …DDS is maturing…
– OMG focus
– Wire spec
– Tools
– Enterprise integration
– Multiple products fielded
– Deployed applications!
! …and adoption is on the rise
– Navy
– DISR
– FCS/SoSCOE
– Many significant applications 4
5. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
The OMG Data Distribution Service
DDS v1.2 API Standard
‣ Language Independent, OS and
HW architecture independent
‣ DCPS. Standard API for Data-
Centric, Topic-Based, Real-Time
Publish/Subscribe
‣ DLRL. Standard API for creating
Object Views out of collection of
Topics
Object/Relational Mapping
Ownership Durability
Content
Subscription
Minimum Profile
Data Centric Publish/Subscribe (DCPS)
Data Local Reconstruction Layer (DLRL)
DDS Interoperability Wire Protocol
Application
UDP/IP
Real-Time Publish/Subscribe Protocol
5
6. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
The OMG Data Distribution Service
DDS v1.2 API Standard
‣ Language Independent, OS and
HW architecture independent
‣ DCPS. Standard API for Data-
Centric, Topic-Based, Real-Time
Publish/Subscribe
‣ DLRL. Standard API for creating
Object Views out of collection of
Topics
Object/Relational Mapping
Ownership Durability
Content
Subscription
Minimum Profile
Data Centric Publish/Subscribe (DCPS)
Data Local Reconstruction Layer (DLRL)
DDS Interoperability Wire Protocol
Application
UDP/IP
Real-Time Publish/Subscribe Protocol
5
7. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
The OMG Data Distribution Service
DDS-RTPS v2.1 Wire Protocol
Standard
‣ Standard wire protocol allowing
interoperability between different
implementations of the DDS
standard
‣ Interoperability demonstrated
among key DDS vendors in March
2009
Object/Relational Mapping
Ownership Durability
Content
Subscription
Minimum Profile
Data Centric Publish/Subscribe (DCPS)
Data Local Reconstruction Layer (DLRL)
DDS Interoperability Wire Protocol
Application
UDP/IP
Real-Time Publish/Subscribe Protocol
6
9. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
What is Data Distribution?
‣ Data distribution is about
making application defined
data available where needed
and when needed
‣ Data is a first class concept,
it can be created, updated,
read and eventually disposed
‣ The last value (or last N-
values) of a Data is available
VehicleSpeedVehicleSpeedVehicleSpeed
plate
“A123”
“B456”
“C789”
dx dy
50 0
0 45
10 30
VehiclePositionVehiclePositionVehiclePosition
plate
“A123”
“B456”
“C789”
x y
101 202
303 404
505 606
[1/2]
TrakCo.VehiclePosition
struct VehiclePosition {
string plate;
long x, y; }
TrakCo.VehicleSpeed
struct VehicleSpeed {
string plate;
long dx, dy; }
Brokers
8
10. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
What is Data Distribution?
‣ Producer, Consumers as well
as Topics are dynamically
discovered
‣ A rich set of QoS is used to
control the non-functional
properties of data (e.g.
durability, availability, etc.)
[2/2]
TrakCo.VehiclePosition
struct VehiclePosition {
string plate;
long x, y; }
TrakCo.VehicleSpeed
struct VehicleSpeed {
string plate;
long dx, dy; }
VehicleSpeedVehicleSpeedVehicleSpeed
plate
“A123”
“B456”
“C789”
dx dy
50 0
0 45
10 30
VehiclePositionVehiclePositionVehiclePosition
plate
“A123”
“B456”
“C789”
x y
101 202
303 404
505 606
Brokers
9
12. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Data in DDS
‣ The definition of Data in DDS is tied
to the definition of a Topic
‣ A Topic is the association between:
‣ Unique Name
‣ Type
‣ QoS
‣ A Topic can have associated a key
in order to express data instances
identities
VehiclePosition
TrackCo.VehiclePosition
{
Reliability
Deadline,
Priority
Transient,
...
}
TopicType QoS
Name
[1/2]
Topics
11
13. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Data in DDS
‣ A Topic key can be made of an
arbitrary number of Topic Type
attributes
‣ Each unique key value identify a
Topic Instance
‣ Topic Instance, can be Created,
Read, Updated, and Disposed
(CRUD)
[2/2]
VehiclePositionVehiclePositionVehiclePosition
plate
“A123”
“B456”
“C789”
x y
101 202
303 202
101 606
TrakCo.VehiclePositionTopic
TopicType
Topic Instances
Topic Key
Topic Instances
12
16. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
QoS Policy Applicabilit
y
RxO Modifiable
DURABILITY
DURABILITY
SERVICE
LIFESPAN
HISTORY
PRESENTATION
RELIABILITY
PARTITION
DESTINATION
ORDER
OWNERSHIP
OWNERSHIP
STRENGTH
DEADLINE
LATENCY
BUDGET
TRANSPORT
PRIORITY
T, DR, DW Y N
Data
Availability
T, DW N N
Data
Availability
T, DW N/A Y
Data
Availability
T, DR, DW N N
Data
Availability
P, S Y N
Data
Delivery
T, DR, DW Y N
Data
Delivery
P, S N Y
Data
Delivery
T, DR, DW Y N
Data
Delivery
T, DR, DW Y N
Data
Delivery
DW N/A Y
Data
Delivery
T, DR, DW Y Y
Data
Timeliness
T, DR, DW Y Y
Data
Timeliness
T, DW N/A Y
Data
Timeliness
TIME BASED
FILTER
RESOURCE
LIMITS
ENTITY
FACTORY
USER DATA
TOPIC DATA
GROUP DATA
LIVELINESS
WRITER DATA
LIFECYCLE
READER DATA
LIFECYCLE
DR N/A Y
Resources
T, DR, DW N N
Resources
Configuratio
n
DP, DR, DW N Y Configuratio
nT N Y
Configuratio
n
P, S N Y
Configuratio
n
T, DR, DW Y N
Configuratio
n
DW N/A Y
Lifecycle
DR N/A Y
Lifecycle
QoS Policy Applicability RxO Modifiable
QoS Policies
15
20. Brokers
VehicleSpeedVehicleSpeedVehicleSpeed
plate dx dy
VehiclePositionVehiclePositionVehiclePosition
plate x y
OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Data Distribution in Action
VehiclePositionVehiclePositionVehiclePosition
plate x y
VehicleSpeedVehicleSpeedVehicleSpeed
plate dx dy
VehiclePositionVehiclePositionVehiclePosition
plate x y
VehiclePositionVehiclePositionVehiclePosition
plate x y
VehiclePositionVehiclePositionVehiclePosition
plate x y
18
21. Brokers
VehicleSpeedVehicleSpeedVehicleSpeed
plate dx dy
VehiclePositionVehiclePositionVehiclePosition
plate x y
OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Data Distribution in Action
VehiclePositionVehiclePositionVehiclePosition
plate x y
VehicleSpeedVehicleSpeedVehicleSpeed
plate dx dy
“A123” 101 202
“A123” 101 202
“A123” 101 202
VehiclePositionVehiclePositionVehiclePosition
plate x y
VehiclePositionVehiclePositionVehiclePosition
plate x y
VehiclePositionVehiclePositionVehiclePosition
plate x y
18
22. Brokers
VehicleSpeedVehicleSpeedVehicleSpeed
plate dx dy
VehiclePositionVehiclePositionVehiclePosition
plate x y
OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Data Distribution in Action
VehiclePositionVehiclePositionVehiclePosition
plate x y
VehicleSpeedVehicleSpeedVehicleSpeed
plate dx dy
“A123” 101 202
“A123” 101 202
“A123” 101 202
VehiclePositionVehiclePositionVehiclePosition
plate x y
VehiclePositionVehiclePositionVehiclePosition
plate x y
“B456” 303 404
“B456” 303 404
“B456” 303 404
VehiclePositionVehiclePositionVehiclePosition
plate x y
18
23. VehiclePositionVehiclePositionVehiclePosition
plate x y
“A123” 101 202
“B456” 303 404
Brokers
VehicleSpeedVehicleSpeedVehicleSpeed
plate dx dy
VehiclePositionVehiclePositionVehiclePosition
plate x y
OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Data Distribution in Action
VehiclePositionVehiclePositionVehiclePosition
plate x y
VehicleSpeedVehicleSpeedVehicleSpeed
plate dx dy
“A123” 101 202“A123” 101 202
VehiclePositionVehiclePositionVehiclePosition
plate x y
“B456” 303 404“B456” 303 404
VehiclePositionVehiclePositionVehiclePosition
plate x y
“A123” 101 202
“B456” 303 404
19
24. VehiclePositionVehiclePositionVehiclePosition
plate x y
“A123” 101 202
“B456” 303 404
Brokers
VehicleSpeedVehicleSpeedVehicleSpeed
plate dx dy
VehiclePositionVehiclePositionVehiclePosition
plate x y
OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Data Distribution in Action
VehiclePositionVehiclePositionVehiclePosition
plate x y
VehicleSpeedVehicleSpeedVehicleSpeed
plate dx dy
“A123” 101 202“A123” 101 202
VehiclePositionVehiclePositionVehiclePosition
plate x y
“B456” 303 404“B456” 303 404
VehiclePositionVehiclePositionVehiclePosition
plate x y
“C789” 505 606
“C789” 505 606
“C789” 505 606
“A123” 101 202
“B456” 303 404
19
25. VehiclePositionVehiclePositionVehiclePosition
plate x y
“A123” 101 202
“B456” 303 404
Brokers
VehicleSpeedVehicleSpeedVehicleSpeed
plate dx dy
VehiclePositionVehiclePositionVehiclePosition
plate x y
OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Data Distribution in Action
VehiclePositionVehiclePositionVehiclePosition
plate x y
VehicleSpeedVehicleSpeedVehicleSpeed
plate dx dy
“A123” 101 202“A123” 101 202
VehiclePositionVehiclePositionVehiclePosition
plate x y
“B456” 303 404“B456” 303 404
VehiclePositionVehiclePositionVehiclePosition
plate x y
“C789” 505 606“C789” 505 606
“A123” 101 202
“B456” 303 404
“C789” 505 606
“C789” 505 606
20
26. VehiclePositionVehiclePositionVehiclePosition
plate x y
“A123” 101 202
“B456” 303 404
Brokers
VehicleSpeedVehicleSpeedVehicleSpeed
plate dx dy
VehiclePositionVehiclePositionVehiclePosition
plate x y
OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Data Distribution in Action
VehiclePositionVehiclePositionVehiclePosition
plate x y
VehicleSpeedVehicleSpeedVehicleSpeed
plate dx dy
“A123” 101 202“A123” 101 202
VehiclePositionVehiclePositionVehiclePosition
plate x y
“B456” 303 404“B456” 303 404
VehiclePositionVehiclePositionVehiclePosition
plate x y
“C789” 505 606“C789” 505 606
“A123” 101 202
“B456” 303 404
“C789” 505 606
“C789” 505 606
“A123” 50 0
20
27. VehiclePositionVehiclePositionVehiclePosition
plate x y
“A123” 101 202
“B456” 303 404
Brokers
VehicleSpeedVehicleSpeedVehicleSpeed
plate dx dy
VehiclePositionVehiclePositionVehiclePosition
plate x y
OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Data Distribution in Action
VehiclePositionVehiclePositionVehiclePosition
plate x y
VehicleSpeedVehicleSpeedVehicleSpeed
plate dx dy
“A123” 101 202“A123” 101 202
VehiclePositionVehiclePositionVehiclePosition
plate x y
“B456” 303 404“B456” 303 404
VehiclePositionVehiclePositionVehiclePosition
plate x y
“C789” 505 606“C789” 505 606
“A123” 101 202
“B456” 303 404
“C789” 505 606
“C789” 505 606
“A123” 50 0
VehicleSpeedVehicleSpeedVehicleSpeed
plate dx dy
21
28. VehiclePositionVehiclePositionVehiclePosition
plate x y
“A123” 101 202
“B456” 303 404
Brokers
VehicleSpeedVehicleSpeedVehicleSpeed
plate dx dy
VehiclePositionVehiclePositionVehiclePosition
plate x y
OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Data Distribution in Action
VehiclePositionVehiclePositionVehiclePosition
plate x y
VehicleSpeedVehicleSpeedVehicleSpeed
plate dx dy
“A123” 101 202“A123” 101 202
VehiclePositionVehiclePositionVehiclePosition
plate x y
“B456” 303 404“B456” 303 404
VehiclePositionVehiclePositionVehiclePosition
plate x y
“C789” 505 606“C789” 505 606
“A123” 101 202
“B456” 303 404
“C789” 505 606
“C789” 505 606
“A123” 50 0
“A123” 50 0
VehicleSpeedVehicleSpeedVehicleSpeed
plate dx dy
21
31. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
What is the problem?
‣ IDL is very good for describing DDS Topic Types, yet...
‣ IDL’s biggest strength, namely (programming) language
independence, becomes its biggest weakness when trying to
define APIs that are well integrated with a programming
language
‣ For some programming languages (e.g. C++) the IDL2C++
mapping is “seasoned”
24
32. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Why is this a problem?
‣ Resulting DDS APIs are more complicated than they should
‣ API don’t feel natural or ergonomic to programmers
‣ API (esp. for C++) don’t integrate well with standard libraries
nor implements common idioms/patterns.
25
33. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Native C++/Java PSMs
‣ The new C++/Java PSM are derived
starting directly from the PIM
‣ The new C++/Java PSM take
advantage of all the features
available in C++/Java to provide a
natural, productive, efficient, safe and
portable API
PIM (UML)
ISO C++ PSM
The new PSM simplify DDS programming w/o limiting the
expensiveness or introducing limitations in what possible
Java 5 PSM
26
34. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
ISO C++ PSM in a Nutshell
‣ Provides transparent, safe, precise and real-time automatic
memory management
‣ Takes advantage of C++ Template Meta-programming to
automate tasks such as type registration and provide a strongly
typed API (no downcast ever!)
‣ Provides a DDS API that exploits Iterators and containers as well
as other C++ Standard Types
‣ API is extensible, efficient and portable
27
44. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Topics in C++
‣ Topic are associated to a C++ template class parametrized in the
topic type, e.g. Topic<VehiclePosition>, Topic<VehicleSpeed>
‣ Topic types can be described in IDL, XML, UML, and Java
‣ Topic types are mapped to C++ classes having one set of
accessors per Topic attribute
37
48. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Topics in Java
‣ Topic are associated to a Java Generic class parametrized in
the topic type, e.g. Topic<VehiclePosition>,
Topic<VehicleSpeed>
‣ Topic types can be described in IDL, XML, UML, and Java
‣ Topic types are mapped to Java classes having one set of
accessors per Topic attribute
‣ Properly annotated, user provided Java classes, can be used as
topic types w/o the need of code generation
41
49. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Types Mapping
‣ DDS primitive types are mapped to
Java primitive types
‣ DDS container types are mapped to
standard Java containers
DDS Type Java Type
Boolean boolean
Char8 char
Char32 int
Byte byte
Int16 short
UInt16 short
Int32 int
Uint32 int
Int64 long
Uint64 long
Float64 double
Float32 float
string<Char8> String
string<Char32> String
sequence<T> Collection
map<K,T> java.util.Map
T[] T[]
42
50. Java Topic Type Mapping
OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
TopicType Mapping
class VehiclePosition {
public VehiclePosition() { /* impl */ }
public VehiclePosition(String plate,
! ! ! int x, int y) { /* impl */}
String getPlate() { /* impl */ }
void setPlate(String plate) { /* impl */ }
int getX() { /* impl */ }
void setX(int x) { /* impl */ }
int getY() { /* impl */ }
void setY(int y) { /* impl */ }
// Private state implementation
}
struct VehiclePosition {
! string plate;
! long x;
! long y;
};
#pragma keylist VehiclePosition plate
IDL Topic Type Definition
43
51. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
JavaTopicType Definition
class VehiclePosition {
@key
private string plate;
private int x;
private int y;
public VehiclePosition() { }
public VehiclePosition(String plate,
! ! ! int x, int y) {
this.plate = plate;
! this.x = x;
! this.y = y;
}
String getPlate() { return this.plate; }
void setPlate(String plate) {
this.plate = plate; }
int getX() { return this.x; }
void setX(int x) { this.x = x; }
int getY() { return this.y; }
void setY(int y) { this.y = y; }
}
44
53. Domain
‣ A Domain is one instance of
the DDS Global Data Space
‣ DDS entities always belong
to a specific domain
Partition
‣ A partition is a scoping
mechanism provided by DDS
organize a partition
OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
DomainId = 0
VechicleTelemetry
Domain and Partitions
46
55. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Joining Domain/Partition
Note:
‣ Reference types are
always created via
factory methods on
the parent entity
‣ Policies can be
“streamed” into QoS
objects
// Create Domain Participant in the Domain “0”
DomainId id = 0;
DomainParticipant dp =
TheParticipantFactory().create_participant(id);
// Set the Publisher QoS with the proper partition
pub::qos::PublisherQos pqos;
pqos << policy::Partition("VehicleTelemetry");
// Create the Publisher
pub::Publisher pub =
dp.create_publisher(pqos);
using namespace dds::core;
using namespace dds;
using namespace dds::domain;
48
57. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Joining Domain/Partition
Note:
‣ The Boostrap class
allows to run multiple
DDS instances, even
from different vendors
on the same
application
// Create Domain Participant in the Domain “0”
DomainId id = 0;
DomainParticipantFactory factory =
! ! DomainParticipantFactory.getInstance
(Bootstrap.createInstance());
DomainParticipant dp =
factory.createParticipant(id);
// Create the Publisher
pub::Publisher pub =
dp.create_publisher(pqos);
import org.omg.dds.core.Bootstrap;
import org.omg.dds.domain.DomainParticipant;
import org.omg.dds.domain.DomainParticipantFactory;
50
60. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Topic Creation
Note:
‣ QoS setting is
optional and only
required to override
defaults
‣ QoS override shown
to highlight how
effective is the new
QoS API
// Create and set TopicQos (if different from
// default)
topic::qos::TopicQos tqos;
tqos << policy::Reliability::Reliable()
<< policy::Durability::Transient()
<< policy::History::KeepLast(10)
<< policy::TransportPriority(14);
// Create the Topic with specific Qos
topic::Topic<VehiclePosition> topic =
dp.create_topic<VehiclePosition>("VPosTopic", tqos);
using namespace dds;
// Create the Topic with default Qos
topic::Topic<VehiclePosition> topic =
dp.create_topic<VehiclePosition>("VPosTopic");
53
65. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Writing Data
Note:
‣ The DataWriter is
parametrized on the
Topic Type
‣ The stream operator
can be used to
write sample as well
as override Qos,
policies and to do
coherent updates
// Create and set DataWriterQos from TopicQos
pub::qos::DataWriterQos dwqos(tqos);
// Create DataWriter
pub::DataWriter<VehiclePosition> dw =
pub.create_datawriter(topic, dwqos);
// Create Sample
VehiclePosition vpos("A123", 100, 200);
// Write
dw.write(vpos);
// Stream-like Write
dw << vpos;
// Stream-like Write + Policy override
dw << policy::TransportPriority(55) << vpos;
using namespace dds::core;
using namespace dds;
58
67. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Writing Data
Note:
‣ No need to pass
the class type since
it is maintained by
the Topic
import org.omg.dds.pub.DataWriter;
// Create the Topic with default Qos
DataWriter<VehiclePosition> dw =
pub.createDataWriter(topic);
// Create Sample
VehiclePosition vp =
new VehiclePosition("A123", 100, 200);
// Write Sample
dw.write(vp);
60
70. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Reading Data
Note:
‣ The read API is heavily
based on iterators
‣ The stream operator can
also be used read
samples and a mutator is
used to control the
read/take behaviour
‣ Back-inserting iterators
and zero-copy API also
supported
// (1) Create and set DataReaderQos from TopicQos
sub::qos::DataReaderQos drqos(tqos);
// (2) Create DataReader
sub::DataReader<VehiclePosition> dr =
sub.create_datareader(topic, drqos);
// (3) Read with using Forward Iterators on std::vector
std::vector<VehiclePosition> data(N);
std::vector<SampleInfo> info(N);
dr.read(data.begin(), info.begin(), N);
// (3) Read with using Forward Iterators on arrays
VehiclePosition adata[N];
SampleInfo ainfo[N];
dr.read(&adata[0], &ainfo[0], N);
using namespace dds::core;
using namespace dds;
63
72. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Reading Data
Note:
‣ No need to pass
the class type since
it is maintained by
the Topic
import org.omg.dds.pub.DataReader;
// Create the Topic with default Qos
DataReader <VehiclePosition> dr =
sub.createDataReader(topic);
List<Sample<VehiclePosition>> data =
new Vector<Sample<VehiclePosition>>();
dr.read(data);
65
73. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Putting all together
int main(int, char**) {
// -- Create Domain Participant
DomainParticipant dp =
! ! TheParticipantFactory().create_participant();
// -- Create Publisher
pub::Publisher pub = dp.create_publisher();
// -- Create Topic
dds::topic::Topic<VehiclePosition> topic =
! ! dp.create_topic<VehiclePosition>("VSPosTopic");
// -- Create DataWriter
pub::DataWriter<VehiclePosition> dw =
! ! ! pub.create_datawriter(topic);
// -- Write Sample
dw << VehiclePosition("A123", 100, 200);
}
‣ Writing a DDS can take as
5 lines of code
‣ Default domain
‣ Default Qos
66
75. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
Concluding Remarks
‣ DDS provide a powerful abstraction for building high available,
scalable and high performance distributed systems
‣ The new C++ and Java API make DDS very simple to use while
improving safety, performances and portability
‣ These new API are now finalized and planned for adoption
during the December 2010 OMG meeting
68
77. OpenSpliceDDSOpenSpliceDDOpenSpliceDDSOpenSpliceDDSOpenSpliceDDS
References
‣ Working incubator from which most of
the ISO C++ PSM was derived
‣ Available at:
‣ http://code.google.com/p/simd-cxx
The Simple DDS API
SimD
‣ OMG submission for C++/Java PSM are also available as Open
Source project at the following URL
‣ http://code.google.com/p/dds-psm-cxx/
‣ http://code.google.com/p/datadistrib4j/
70