Kerstin Keller
2018-08-28 09:04:39 UTC
Hi,
we have a communication middleware framework in place (quite similar to ROS
- with publish / subscribe patterns) and would like to integrate Capnproto
for message descriptions.
For Pub / Sub itself we have classes that can send and receive binary data
(to / from a std::string), so I'd like to build on that.
The idea is to have:
// Initialize a Publisher
Publisher<AddressBook> pub("address_book");
AddressBook::Builder addressBook = pub.getBuilder();
//manipulate the addressBook
auto people = addressBook.initPeople(2);
//...
// Send out the data
pub.Send();
So far, so good, I can send and receive data without problem.
The ecosystem, like ROS, also has recording possibilities. To be able to
interpret data on the fly and later on, I need the capnproto reflection
capabilities. So what I really need is to register the AddressBook (Binary)
Schema with the framework when a publisher is created.
But from the examples I really don't understand how this can be done. My
framework let's me store and retrieve reflection information as a
std::string. So I feel that I have to "serialize" the Schema information
into a string somehow, and rebuild it from a string. Since a schema also a
.capnp description it feels like this is something that can be done, but I
don't seem to grasp how it can be done.
So what I need is basically to implement these two functions:
template <typename T>
std::string getSchemaAsString<T>();
and
DynamicStruct::Reader getReader(const std::string& schema_string);
What I tried:
// This gives me the Schema. But is there a builder underneath?
auto schema = capnp::Schema::from<AddressBook>();
or do I need a SchemaLoader
capnp::SchemaLoader loader;
loader.loadCompiledTypeAndDependencies<AddressBook>();
And the other question, does it make sense to work with a `
MallocMessageBuilder` when I will later send out the data in a std::string
object, or does it make sense to Implement a `StdStringMessageBuilder`?
Any hints will be highly appreciated.
we have a communication middleware framework in place (quite similar to ROS
- with publish / subscribe patterns) and would like to integrate Capnproto
for message descriptions.
For Pub / Sub itself we have classes that can send and receive binary data
(to / from a std::string), so I'd like to build on that.
The idea is to have:
// Initialize a Publisher
Publisher<AddressBook> pub("address_book");
AddressBook::Builder addressBook = pub.getBuilder();
//manipulate the addressBook
auto people = addressBook.initPeople(2);
//...
// Send out the data
pub.Send();
So far, so good, I can send and receive data without problem.
The ecosystem, like ROS, also has recording possibilities. To be able to
interpret data on the fly and later on, I need the capnproto reflection
capabilities. So what I really need is to register the AddressBook (Binary)
Schema with the framework when a publisher is created.
But from the examples I really don't understand how this can be done. My
framework let's me store and retrieve reflection information as a
std::string. So I feel that I have to "serialize" the Schema information
into a string somehow, and rebuild it from a string. Since a schema also a
.capnp description it feels like this is something that can be done, but I
don't seem to grasp how it can be done.
So what I need is basically to implement these two functions:
template <typename T>
std::string getSchemaAsString<T>();
and
DynamicStruct::Reader getReader(const std::string& schema_string);
What I tried:
// This gives me the Schema. But is there a builder underneath?
auto schema = capnp::Schema::from<AddressBook>();
or do I need a SchemaLoader
capnp::SchemaLoader loader;
loader.loadCompiledTypeAndDependencies<AddressBook>();
And the other question, does it make sense to work with a `
MallocMessageBuilder` when I will later send out the data in a std::string
object, or does it make sense to Implement a `StdStringMessageBuilder`?
Any hints will be highly appreciated.
--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+***@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+***@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.