-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Publish Recorder Command Type Object
Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
- Loading branch information
1 parent
7b678b9
commit 46c0f97
Showing
4 changed files
with
320 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
255 changes: 255 additions & 0 deletions
255
...corder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandTypeObject.cxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,255 @@ | ||
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/*! | ||
* @file DdsRecorderCommandTypeObject.cpp | ||
* This source file contains the definition of the described types in the IDL file. | ||
* | ||
* This file was generated by the tool gen. | ||
*/ | ||
|
||
#ifdef _WIN32 | ||
// Remove linker warning LNK4221 on Visual Studio | ||
namespace { char dummy; } | ||
#endif | ||
|
||
#include "DdsRecorderCommand.h" | ||
#include "DdsRecorderCommandTypeObject.h" | ||
#include <mutex> | ||
#include <utility> | ||
#include <sstream> | ||
#include <fastrtps/rtps/common/SerializedPayload.h> | ||
#include <fastrtps/utils/md5.h> | ||
#include <fastrtps/types/TypeObjectFactory.h> | ||
#include <fastrtps/types/TypeNamesGenerator.h> | ||
#include <fastrtps/types/AnnotationParameterValue.h> | ||
#include <fastcdr/FastBuffer.h> | ||
#include <fastcdr/Cdr.h> | ||
|
||
using namespace eprosima::fastrtps::rtps; | ||
|
||
void registerDdsRecorderCommandTypes() | ||
{ | ||
static std::once_flag once_flag; | ||
std::call_once(once_flag, []() | ||
{ | ||
TypeObjectFactory *factory = TypeObjectFactory::get_instance(); | ||
factory->add_type_object("DdsRecorderCommand", GetDdsRecorderCommandIdentifier(true), | ||
GetDdsRecorderCommandObject(true)); | ||
factory->add_type_object("DdsRecorderCommand", GetDdsRecorderCommandIdentifier(false), | ||
GetDdsRecorderCommandObject(false)); | ||
|
||
}); | ||
} | ||
|
||
const TypeIdentifier* GetDdsRecorderCommandIdentifier(bool complete) | ||
{ | ||
const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("DdsRecorderCommand", complete); | ||
if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) | ||
{ | ||
return c_identifier; | ||
} | ||
|
||
GetDdsRecorderCommandObject(complete); // Generated inside | ||
return TypeObjectFactory::get_instance()->get_type_identifier("DdsRecorderCommand", complete); | ||
} | ||
|
||
const TypeObject* GetDdsRecorderCommandObject(bool complete) | ||
{ | ||
const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsRecorderCommand", complete); | ||
if (c_type_object != nullptr) | ||
{ | ||
return c_type_object; | ||
} | ||
else if (complete) | ||
{ | ||
return GetCompleteDdsRecorderCommandObject(); | ||
} | ||
//else | ||
return GetMinimalDdsRecorderCommandObject(); | ||
} | ||
|
||
const TypeObject* GetMinimalDdsRecorderCommandObject() | ||
{ | ||
const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsRecorderCommand", false); | ||
if (c_type_object != nullptr) | ||
{ | ||
return c_type_object; | ||
} | ||
|
||
TypeObject *type_object = new TypeObject(); | ||
type_object->_d(EK_MINIMAL); | ||
type_object->minimal()._d(TK_STRUCTURE); | ||
|
||
type_object->minimal().struct_type().struct_flags().IS_FINAL(false); | ||
type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); | ||
type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); | ||
type_object->minimal().struct_type().struct_flags().IS_NESTED(false); | ||
type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported | ||
|
||
MemberId memberId = 0; | ||
MinimalStructMember mst_command; | ||
mst_command.common().member_id(memberId++); | ||
mst_command.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported | ||
mst_command.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported | ||
mst_command.common().member_flags().IS_EXTERNAL(false); // Unsupported | ||
mst_command.common().member_flags().IS_OPTIONAL(false); | ||
mst_command.common().member_flags().IS_MUST_UNDERSTAND(false); | ||
mst_command.common().member_flags().IS_KEY(false); | ||
mst_command.common().member_flags().IS_DEFAULT(false); // Doesn't apply | ||
mst_command.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); | ||
|
||
|
||
MD5 command_hash("command"); | ||
for(int i = 0; i < 4; ++i) | ||
{ | ||
mst_command.detail().name_hash()[i] = command_hash.digest[i]; | ||
} | ||
type_object->minimal().struct_type().member_seq().emplace_back(mst_command); | ||
|
||
MinimalStructMember mst_args; | ||
mst_args.common().member_id(memberId++); | ||
mst_args.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported | ||
mst_args.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported | ||
mst_args.common().member_flags().IS_EXTERNAL(false); // Unsupported | ||
mst_args.common().member_flags().IS_OPTIONAL(false); | ||
mst_args.common().member_flags().IS_MUST_UNDERSTAND(false); | ||
mst_args.common().member_flags().IS_KEY(false); | ||
mst_args.common().member_flags().IS_DEFAULT(false); // Doesn't apply | ||
mst_args.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); | ||
|
||
|
||
MD5 args_hash("args"); | ||
for(int i = 0; i < 4; ++i) | ||
{ | ||
mst_args.detail().name_hash()[i] = args_hash.digest[i]; | ||
} | ||
type_object->minimal().struct_type().member_seq().emplace_back(mst_args); | ||
|
||
|
||
// Header | ||
// TODO Inheritance | ||
//type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); | ||
//type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; | ||
|
||
TypeIdentifier identifier; | ||
identifier._d(EK_MINIMAL); | ||
|
||
SerializedPayload_t payload(static_cast<uint32_t>( | ||
MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); | ||
eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); | ||
// Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) | ||
eprosima::fastcdr::Cdr ser( | ||
fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, | ||
eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. | ||
payload.encapsulation = CDR_LE; | ||
|
||
type_object->serialize(ser); | ||
payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length | ||
MD5 objectHash; | ||
objectHash.update((char*)payload.data, payload.length); | ||
objectHash.finalize(); | ||
for(int i = 0; i < 14; ++i) | ||
{ | ||
identifier.equivalence_hash()[i] = objectHash.digest[i]; | ||
} | ||
|
||
TypeObjectFactory::get_instance()->add_type_object("DdsRecorderCommand", &identifier, type_object); | ||
delete type_object; | ||
return TypeObjectFactory::get_instance()->get_type_object("DdsRecorderCommand", false); | ||
} | ||
|
||
const TypeObject* GetCompleteDdsRecorderCommandObject() | ||
{ | ||
const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsRecorderCommand", true); | ||
if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) | ||
{ | ||
return c_type_object; | ||
} | ||
|
||
TypeObject *type_object = new TypeObject(); | ||
type_object->_d(EK_COMPLETE); | ||
type_object->complete()._d(TK_STRUCTURE); | ||
|
||
type_object->complete().struct_type().struct_flags().IS_FINAL(false); | ||
type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); | ||
type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); | ||
type_object->complete().struct_type().struct_flags().IS_NESTED(false); | ||
type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported | ||
|
||
MemberId memberId = 0; | ||
CompleteStructMember cst_command; | ||
cst_command.common().member_id(memberId++); | ||
cst_command.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported | ||
cst_command.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported | ||
cst_command.common().member_flags().IS_EXTERNAL(false); // Unsupported | ||
cst_command.common().member_flags().IS_OPTIONAL(false); | ||
cst_command.common().member_flags().IS_MUST_UNDERSTAND(false); | ||
cst_command.common().member_flags().IS_KEY(false); | ||
cst_command.common().member_flags().IS_DEFAULT(false); // Doesn't apply | ||
cst_command.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); | ||
|
||
|
||
cst_command.detail().name("command"); | ||
|
||
type_object->complete().struct_type().member_seq().emplace_back(cst_command); | ||
|
||
CompleteStructMember cst_args; | ||
cst_args.common().member_id(memberId++); | ||
cst_args.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported | ||
cst_args.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported | ||
cst_args.common().member_flags().IS_EXTERNAL(false); // Unsupported | ||
cst_args.common().member_flags().IS_OPTIONAL(false); | ||
cst_args.common().member_flags().IS_MUST_UNDERSTAND(false); | ||
cst_args.common().member_flags().IS_KEY(false); | ||
cst_args.common().member_flags().IS_DEFAULT(false); // Doesn't apply | ||
cst_args.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); | ||
|
||
|
||
cst_args.detail().name("args"); | ||
|
||
type_object->complete().struct_type().member_seq().emplace_back(cst_args); | ||
|
||
|
||
// Header | ||
type_object->complete().struct_type().header().detail().type_name("DdsRecorderCommand"); | ||
// TODO inheritance | ||
|
||
|
||
TypeIdentifier identifier; | ||
identifier._d(EK_COMPLETE); | ||
|
||
SerializedPayload_t payload(static_cast<uint32_t>( | ||
CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); | ||
eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); | ||
// Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) | ||
eprosima::fastcdr::Cdr ser( | ||
fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, | ||
eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. | ||
payload.encapsulation = CDR_LE; | ||
|
||
type_object->serialize(ser); | ||
payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length | ||
MD5 objectHash; | ||
objectHash.update((char*)payload.data, payload.length); | ||
objectHash.finalize(); | ||
for(int i = 0; i < 14; ++i) | ||
{ | ||
identifier.equivalence_hash()[i] = objectHash.digest[i]; | ||
} | ||
|
||
TypeObjectFactory::get_instance()->add_type_object("DdsRecorderCommand", &identifier, type_object); | ||
delete type_object; | ||
return TypeObjectFactory::get_instance()->get_type_object("DdsRecorderCommand", true); | ||
} |
63 changes: 63 additions & 0 deletions
63
ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandTypeObject.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/*! | ||
* @file DdsRecorderCommandTypeObject.h | ||
* This header file contains the declaration of the described types in the IDL file. | ||
* | ||
* This file was generated by the tool gen. | ||
*/ | ||
|
||
#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_TYPE_OBJECT_H_ | ||
#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_TYPE_OBJECT_H_ | ||
|
||
|
||
#include <fastrtps/types/TypeObject.h> | ||
#include <map> | ||
|
||
#if defined(_WIN32) | ||
#if defined(EPROSIMA_USER_DLL_EXPORT) | ||
#define eProsima_user_DllExport __declspec( dllexport ) | ||
#else | ||
#define eProsima_user_DllExport | ||
#endif | ||
#else | ||
#define eProsima_user_DllExport | ||
#endif | ||
|
||
#if defined(_WIN32) | ||
#if defined(EPROSIMA_USER_DLL_EXPORT) | ||
#if defined(DdsRecorderCommand_SOURCE) | ||
#define DdsRecorderCommand_DllAPI __declspec( dllexport ) | ||
#else | ||
#define DdsRecorderCommand_DllAPI __declspec( dllimport ) | ||
#endif // DdsRecorderCommand_SOURCE | ||
#else | ||
#define DdsRecorderCommand_DllAPI | ||
#endif | ||
#else | ||
#define DdsRecorderCommand_DllAPI | ||
#endif // _WIN32 | ||
|
||
using namespace eprosima::fastrtps::types; | ||
|
||
eProsima_user_DllExport void registerDdsRecorderCommandTypes(); | ||
|
||
eProsima_user_DllExport const TypeIdentifier* GetDdsRecorderCommandIdentifier(bool complete = false); | ||
eProsima_user_DllExport const TypeObject* GetDdsRecorderCommandObject(bool complete = false); | ||
eProsima_user_DllExport const TypeObject* GetMinimalDdsRecorderCommandObject(); | ||
eProsima_user_DllExport const TypeObject* GetCompleteDdsRecorderCommandObject(); | ||
|
||
|
||
#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_TYPE_OBJECT_H_ |