Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/dynamic types #276

Merged
merged 226 commits into from
Oct 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
226 commits
Select commit Hold shift + click to select a range
22b7766
Refs #3079. Initial structure of classes for the dynamic objects.
Jun 27, 2018
1d4cf5b
Refs #3079 Move some classes to another header file.
Jun 27, 2018
b6d5786
Refs #3079. Update AnnotationDescriptor and MemberDescriptor classes.
Jun 27, 2018
b222abf
Refs #3079 Update the Dynamic Types Management.
Jun 28, 2018
57d5fc5
Refs #3079 Rename file DynamicTypeBuilderFactory
Jun 28, 2018
3457b35
Refs #3079 Rename file DynamicTypeBuilderFactory
Jun 28, 2018
e134968
Refs #3079. Manage the memory on every class of dynamic types
Jun 28, 2018
c405b3e
Refs #3078 TypeObject and inner classes.
Sep 13, 2018
0b1a9ac
Refs #3079 Implement several method to modify the attributes of the D…
Jun 29, 2018
7aefe01
Merge branch 'dynamicTypes' of https://192.168.1.4/LuisGasco/fastrtps…
Jun 29, 2018
f071344
Refs #3078 Compilation errors solved.
Sep 13, 2018
22fa6ec
Refs #3079 Fix compilation errors on Windows.
Jul 2, 2018
e1dcf7a
Refs #3078 Fixing warnings
Jul 2, 2018
4c14139
Refs #3079. Merge MemberId into TypesBase header file
Jul 2, 2018
6f70763
Refs #3079. Update Dynamic Data without DYNAMIC_TYPES_CHECKING
Jul 2, 2018
04af59b
Refs #3079. Remove unnecessary method from DynamicData
Jul 3, 2018
fdfd006
Refs #3079. Update DynamicData class.
Jul 3, 2018
1fb533d
Refs #3079. Add log errors to dynamic type classes
Jul 3, 2018
a3d7d6a
Refs #3079. Implement several tests for int32 and strings to test the…
Jul 3, 2018
194dbac
Refs #3078 Adding infrastructure to generate TypeObjects from IDL.
Jul 3, 2018
17331d8
Refs #3078 Fixed warnings on gcc.
Jul 3, 2018
a19d4c6
Refs #3079. Implement support for ALIAS types
Jul 3, 2018
57f0ca7
Refs #3083. Implement support for Dynamic Sequences.
Jul 4, 2018
e3b285f
Refs #3083 Implement support for bitsets
Jul 4, 2018
43782d2
Refs #3083. Implement support for Bitmasks
Jul 4, 2018
db043c8
Refs #3083 Fix issues with the tests
Jul 4, 2018
ea88183
Refs #3083 Add a new macro to ENABLE / DISABLE the extra memory manag…
Jul 4, 2018
69e0adc
Refs #3083 Refactor several method names to keep consistency.
Jul 4, 2018
5494f9f
Refs #3083. Implement support for enums
Jul 5, 2018
96bfa7e
Refs #3083 Implement support for maps and arrays
Jul 5, 2018
5537f20
Refs #3083. Implement support for structs
Jul 5, 2018
8e09490
Refs #3083 Implement support for Unions
Jul 5, 2018
39caea0
Merge branch 'dynamicTypes' of https://192.168.1.4/LuisGasco/fastrtps…
Jul 5, 2018
06ce265
Refs# 3083. Update the unit tests to check the incompatibilities betw…
Jul 5, 2018
322a726
Refs #3083. Add Clone - Equals checking for every kind of DynamicType.
Jul 5, 2018
cdfa49b
Refs #3083 Generate complex tests to check recursive types ( struct w…
Jul 6, 2018
af9c578
Refs #3083. Complete remaining TODOs
Jul 6, 2018
9c4b0ef
Refs #3184 TypeObjectFactory and TypeIdentifier (+TypeObject) -> Dyna…
Jul 9, 2018
2e8a299
Refs #3080. Add the new fields used by the types discovery.
Jul 9, 2018
4f443c6
Refs #3083 Implement support for structs heritage.
Jul 9, 2018
347470f
Refs #3082 Added method to get TypeObject and TypeIdentifier from Typ…
Jul 9, 2018
a8351ae
Refs #3082 Added parameters for TypeIdV1 and TypeObjectV1 on discovery.
Jul 9, 2018
a05fd2f
Refs #3083 Implement the serialization and deserialization for Dynam…
Jul 10, 2018
92fd33d
Refs #3184 Bug fixing
Jul 10, 2018
36c0f71
Refs #3184 Warning fixing.
Jul 10, 2018
4a81182
Refs #3083. Fix compilation warnings and new dependences on the unit …
Jul 10, 2018
a466b22
Refs #3085 DynamicHelloWorldExample
Jul 10, 2018
346fe80
Refs #3083. Implement additional methods for bitmasks
Jul 10, 2018
af17399
Refs #3082 Added TypeIdentifier discovery.
Jul 10, 2018
8923494
Refs #3085 Fix link issue on Windows.
Jul 10, 2018
4e0d59e
Refs #3082 Fixed manual setup.
Jul 10, 2018
6c8f9ff
Refs #3082 DynHello
Jul 10, 2018
0436612
Refs #3085. Add new test to check edge cases.
Jul 10, 2018
5ea6410
Refs #3082 DynamicHelloWorld and some fixes.
Jul 10, 2018
8ee27af
Refs #3080 Fixed double free due to change from object to pointer.
Jul 11, 2018
cbc4701
Refs #3187 SetXXXValue, parameters switched
Jul 11, 2018
cc46dc2
Refs #3085. Add Tests for serialization - deserialization of the diff…
Jul 11, 2018
988f751
Refs #3085 Merge Tests with previous commits
Jul 11, 2018
6e3f945
Refs #3085 Update tests with the same format for Sets.
Jul 11, 2018
75dcc60
Refs #3187 Publisher using dynamic data (WIP)
Jul 11, 2018
7a9a912
Refs #3187 WIP: Subscriber using Dynamic data and added additional Ge…
Jul 11, 2018
473eabf
Refs #3187 Added COMPLETE checking and DiscoveryKind mismatch.
Jul 11, 2018
9606ed8
Refs #3187 Added DeleteType and DeleteData calls.
Jul 11, 2018
3ac32ca
Refs #3085. Implement the serialization for dynamic types and the rel…
Jul 11, 2018
c70c722
Refs #3085. Fix compilation errors.
Jul 11, 2018
6782b70
Refs #3085 Fix link issues with the type identifiers
Jul 11, 2018
ad1d9f3
Refs #3187 Added RTPS_DllAPI to TypeObject hierarchy
Jul 11, 2018
e68894b
Refs #3187 Dynamic Data WIP
Jul 11, 2018
3b12fe9
Revert "Refs #3187 Added RTPS_DllAPI to TypeObject hierarchy"
Jul 11, 2018
9e19c27
Refs #3085 Block the constructors of DynamicType and DynamicData to f…
Jul 12, 2018
31d9e48
Refs #3085. Update CDR sizes calculation to fit the sizes of the IDLs.
Jul 12, 2018
0c9abb7
Refs #3187 Serialization fixed to make it compatible with IDL.
Jul 12, 2018
21c503d
Refs #3085 Fix issues with ARRAYS
Jul 12, 2018
09a07b8
Refs #3085. Create an optimization for arrays where there is a "defau…
Jul 12, 2018
4efd220
Refs #3085. Add Helper functions to reduce the lines of code needed b…
Jul 12, 2018
1fa3911
Refs #3187 Added DynamicComplexTypesTest and fixing due to valgrind r…
Jul 12, 2018
f838114
Refs #3187 Fixed unordered warning.
Jul 12, 2018
a0489f5
Refs #3085 Fix issues with the new descriptor interface.
Jul 12, 2018
6cb1ad9
Refs #3187 Fixing valgrind results.
Jul 12, 2018
85f9e7a
Refs #3187 Fixed double free on DynamicType deletion.
Jul 12, 2018
b45748a
Refs #3187 DynamicHelloWorldExample valgrind passed with all combinat…
Jul 12, 2018
9416896
Refs #3085. Add new methods to ease the creation of members for a com…
Jul 13, 2018
8cf8de0
Refs #3187 Fixes
Jul 13, 2018
9b1b8a0
Refs #3085. Add a new feature to work with unions with complex types.
Jul 13, 2018
0eb7f51
Refs #3187 Bug fixing
Jul 13, 2018
ba77519
Refs #3085 Update the code of the publisher and the subscriber with t…
Jul 13, 2018
a8b60d2
Refs #3085. Adapt wchar to uint32 after checking that linux & MacOS w…
Jul 13, 2018
175a709
Refs #3085. Adapt WSTRINGs to work with uint32_t
Jul 13, 2018
3833373
Refs #3187 Fixed warning in generated code.
Jul 13, 2018
1234de5
Refs #3187 Fixed warning in generated code.
Jul 13, 2018
e91eb77
Refs #3085. Adapt the Dynamic Complex Types Test to the new interface…
Jul 13, 2018
a122906
Refs #3187 Fixing Tests.
Jul 13, 2018
5ea6aca
Refs #3187 Development of TypeObject to DynamicTypeFactory preparation.
Jul 13, 2018
414729e
Refs #3187 Fixing conversions methods. Added test.
Jul 13, 2018
b3be36a
Refs #3085 Review the creation of DynamicTypes in the TypeObjectFactory
Jul 13, 2018
1d5e9ea
Refs #3085. Fix compilation warning
Jul 13, 2018
132ac77
Refs #3193. Implement Keyed Topics for Dynamic Types.
Jul 16, 2018
13db4f3
Refs #3187 Matching fixes
Jul 16, 2018
051c83c
Refs #3187 Warning fix and test idl regeneration.
Jul 16, 2018
c6f2cee
Refs #3187 Fixed issue with long double
Jul 16, 2018
6252d94
Refs #3194 Added operator== for TypeIdentifier
Jul 17, 2018
94d3f1f
Refs #3194 Fixed errata on IDL
Jul 17, 2018
4a351a5
Refs #3194. Add new unit test to check the TypeIndentifers used durin…
Jul 17, 2018
4f1f56e
Refs #3194 Factory's destructor deletes its pointers.
Jul 17, 2018
fbfcb2b
Refs #3194 Added basic types to operator==
Jul 17, 2018
da46938
Refs #3194 Fixed Helloworld not calling DeleteInstance methods.
Jul 17, 2018
ad2f6af
Refs #3194. Update unit tests and create a new class to manage the me…
Jul 17, 2018
37b617a
Refs #3194 Factories cleanup on stopAll
Jul 17, 2018
808e454
Refs #3203 Refactor generator from IDL.
Jul 17, 2018
5dfd66e
Refs #3203 Fixed fastrtpsgen and generated file.
Jul 17, 2018
dc00db8
Refs #3204. First step of the refactor using shared_ptrs for DynamicT…
Jul 17, 2018
7c9ad40
Refs #3204. Update Complex Unit Tests to use the new interface for Dy…
Jul 18, 2018
fc26617
Refs #3204. Update Dynamic Tests to use the new interface for Dynamic…
Jul 18, 2018
f7a3a58
Refs #3204. Update Dynamic Hello World example to show the two ways t…
Jul 18, 2018
28e6c71
Refs #3204. Adapt Dynamic Data creation for rtps historic
Jul 18, 2018
9082fa2
Refs #3204 Create the DynamicPubSubType to optimize the memory manage…
Jul 18, 2018
4006208
Refs #3197 Bug fixing
Jul 18, 2018
debdda8
Refs #3197 Merge fixing
Jul 18, 2018
469dbeb
Refs #3197. Merge changes
Jul 18, 2018
b607c38
Refs #3197 Fix memory issues in TypeObjectFactory
Jul 18, 2018
6499053
Refs #3204. Fix an issue with a string copy in a method of dynamic ty…
Sep 13, 2018
362b5cf
Refs #3204. Fix compilation errors with the macro DISABLE_DYNAMIC_MEM…
Jul 18, 2018
312489d
Refs #3204 Fixed memory leaks
Jul 19, 2018
1f6284b
Refs #3204 Add a new parameter to CreateCustomBuilder to set the name…
Jul 19, 2018
7fb0824
Refs #3197 Fixing DynamicType generation from TypeObject
Jul 19, 2018
7aa094b
Refs #3197. Update several methods to avoid unnecessary copies
Jul 19, 2018
46fdcf7
Refs #3197 Fixed generating inner types as minimal
Jul 19, 2018
c884849
Refs #3197 Fixing bugs
Jul 19, 2018
abeebb7
Refs #3197 Fixing complex types on plain types.
Jul 19, 2018
8b63ddd
Refs #3197 Some refactoring after cherry-picking
Sep 13, 2018
d8052a6
Refs #3197 Updated HelloWorld
Jul 19, 2018
ba8a8d2
Refs #3197. Fix issues related to unions with auto generated dynamic …
Jul 19, 2018
f82dd0b
Refs #3198 DynamicType to TypeObject first attemp
Jul 19, 2018
ba77970
Refs #3204. Fix DynamicDataFactory desctruction method
Jul 19, 2018
8070bca
Refs #3077 Partial fix one inconsistency between the serialization o…
Jul 20, 2018
a20cb8c
Refs #3198 Several fixes
Jul 20, 2018
c65b702
Refs #3216 Added Basic idl and preparing more tests.
Jul 20, 2018
eaf47cf
Refs #3077. Update unions to work like IDLs
Jul 20, 2018
b4365a7
Refs #3216 Preparing tests
Jul 20, 2018
d27769a
Refs #3077. Update unions to work like IDLs
Jul 20, 2018
0b0d412
Refs #3216 Fixed names in struct members
Jul 20, 2018
4e64ee2
Refs #3216 Fixed unreachable code warnings
Jul 20, 2018
7460872
Refs #3216 Fixed long double size
Jul 20, 2018
f823212
Refs #3077. Fix WString serialization
Jul 20, 2018
ef8ad7b
Refs #3077 Add test to serialize every type supported by IDLs and Dyn…
Jul 20, 2018
0f20bf0
Refs #3221. Remove debug traces
Jul 20, 2018
827b1fa
Refs #3216 Added size to maps
Jul 20, 2018
48c72b1
Refs #3216 Added unions on structs
Jul 20, 2018
0dd3a35
Refs #3221. Update unit tests with more checks
Jul 20, 2018
06b0ef4
Refs #3077. Fix alingment issue with float128
Jul 23, 2018
e141cb6
Refs #3221 Fix alignment for long double
Jul 23, 2018
e05f021
Refs #3221 throw in new line and between brackets
Jul 23, 2018
5838fb4
Refs #3077. Fix issue with the serialization of byte values.
Jul 23, 2018
b711f6c
Refs #3077. Update the dynamic Datas deletion to avoid crashes on exc…
Jul 23, 2018
053f4ec
Refs #3077 Disable test because the interface doesn't support the kin…
Jul 23, 2018
0b36e21
Refs #3221 Fixed unitialized TopicDiscoveryKind
Jul 23, 2018
9377380
Refs #3221 Fixed discovery with minimal.
Jul 23, 2018
56f663f
Refs #3228. Fix DinamicPubSubType to add 4 bytes of the encoding.
Jul 24, 2018
dd4ceba
Refs #3228 Add a Clone feature to the dynamic datas.
Jul 24, 2018
f0899b2
Refs #3227 Fixes and regeneration of cxx files.
Jul 24, 2018
8c962f4
Refs #3228 Update WSTRING serialization removing the '/0' because of …
Jul 24, 2018
3087543
Refs #3228 Add new methods to access to the serialized payload of the…
Jul 25, 2018
3c55fb3
Refs #3228 Add new Methods to DynamicData to ease the management of s…
Jul 25, 2018
158b80a
Refs #3228 Add new insert methods to ease the management of maps.
Jul 25, 2018
0484801
Refs #3227 Keyed Struct for testing
Jul 24, 2018
a71b883
Refs #3227 Some fixes in tests
Jul 25, 2018
b1d9dfc
Refs #3227 WIP (Test Failing)
Jul 25, 2018
c615251
Refs #3228 Fix issue with enums as discriminators of union types
Jul 25, 2018
a088012
Refs #3228 Fix issue getting the index of an element in a dynamic array
Jul 25, 2018
507c1f6
Refs #3228. Update SetcomplexValue to add elements to dynamic arrays
Jul 25, 2018
355a6f2
Refs #3227 Fix serialization issues with Aliases and Maps
Jul 26, 2018
f9ca7b5
Refs #3227 Update Complex Tests to compare the serialization between …
Jul 26, 2018
9b335d0
Refs #3227 Fixed uninitialized arrays
Jul 26, 2018
eba9a9b
Refs #3227 Add shared_ptr to the custom type builder
Jul 26, 2018
2d904e2
Refs #3227. Fix several issues cloning Dynamic Datas
Jul 26, 2018
59a7b41
Refs #3227. Add more tests to check every combination of the complex …
Jul 26, 2018
5008b7c
Refs #3227. Create a shared_ptr for dynamicDatas to ease the manageme…
Jul 26, 2018
5b0258b
Refs #3227 Added test with keys
Jul 26, 2018
8ce953c
Refs #3227 Fix issue on Keys Test
Jul 26, 2018
a8c9a68
Refs #3227. Finish the test with keys.
Jul 26, 2018
68404db
Refs #3227 update the keys test to compare the serialization of the I…
Jul 26, 2018
13f75e7
Refs #3229. Fix memory leak
Jul 27, 2018
ffb536e
Refs #3227. Add a new method to clean the values removing a compilat…
Jul 27, 2018
26f0ae3
Refs #3229 Add security to make the Dynamic factories thread-safe
Jul 27, 2018
2c2d4e5
Refs #3229 Add methods to get the serializedPayload of the subscriber…
Jul 27, 2018
679c355
Refs #3229 Added Methods to publish an already built SerializedPayload
Jul 27, 2018
0290e41
Refs #3229 Update the method takeNextSerializedPayload
Jul 30, 2018
0074b33
Refs #3229 Fix payload copy during the publish process.
Jul 30, 2018
ed41018
Refs #3237 Create and delete keyed data on subscriber history only if…
Jul 30, 2018
649a073
Refs #3229 Fix crash during the publish of a serialized payload
Jul 30, 2018
10efc5b
Refs #3244 Create new helper functions to block possible issues with …
Jul 31, 2018
44dd5f7
Refs #3263 Fixed IDL included files on TypeObject. Fixes warnings.
Jul 31, 2018
13630d1
Refs #3263 Added argument to generate type object files.
Jul 31, 2018
2c59376
Refs #3265. Add management for dynamic types
Jul 31, 2018
60e824d
Refs #3010. Fixed error generating CMakeLists.txt
richiware Jun 20, 2018
a6e014f
Refs #3226 Hide the destructors of the Dynamic Types to block the del…
Jul 31, 2018
ac868ad
Refs #3265 Fixes on benchmark and TypeNamesGenerator.
Aug 1, 2018
15afe4d
Refs #3267. Implement some modifications from the merge request
Aug 1, 2018
f5cc6fa
Refs #3267. Implement some modifications from the merge request
Sep 13, 2018
7288284
Refs #3267. Restore removed code to override operators with ProtocolV…
Aug 1, 2018
332357a
Refs #3267 Fixed error on parser (due to merge?)
Aug 3, 2018
cdf017c
Refs #3276
Aug 3, 2018
f28cd2e
Refs #3276 Unitialized key buffer.
Aug 6, 2018
28ca670
Refs #3276 Unitialized key buffer.
Aug 6, 2018
fe06c98
Refs #3287 Added mechanism to remove profiles from XMLProfileManager …
Aug 29, 2018
de4632d
Refs #3289 Added dynamic type generation by XML
Sep 4, 2018
70ff6c0
Refs #3289 Added enum, typdef, map, and inner types as nodes instead …
Sep 5, 2018
2ae041c
Refs #3387 Dynamic Types in its own branch
Sep 13, 2018
0b632dc
Refs #3371 Requested changes in GitHub
Sep 17, 2018
cf933f9
Refs #3538 Rebase related fixes
Oct 15, 2018
bd0aa43
Refs #3538 Dynamic types merge
Oct 15, 2018
6fcde4d
Refs #3538 Regenerated files from idl as test of the merge.
Oct 16, 2018
a4d3f60
Refs #3538 PR requested changes.
Oct 16, 2018
50e2f93
Refs #3538 Using quotes instead angled brackets.
richiware Oct 17, 2018
78ddfca
Refs #3538 Make DynamicHelloWorld communicate with classic HelloWorld.
Oct 17, 2018
c347b8a
Refs #3563. Fix compilation warnings and linking errors on Windows
Oct 18, 2018
83f0721
Refs #3563. Create a mocked QosPolicies to remove the dependency with…
Oct 18, 2018
b2f723c
Refs #3563. Fix issues with tabs.
Oct 18, 2018
8e0dfde
#3538 Rename XML Tag "transports" and "transport" for "transport_desc…
Oct 18, 2018
88466dc
Refs #3565. Update the parsing of publishers and subscribers to use o…
Oct 18, 2018
89424c6
Refs #3538 Create a releaser objects to delete the dynamic factories …
Oct 18, 2018
4430c58
Refs #3538. Fixing compile error on a security test.
richiware Oct 19, 2018
9c6c754
Refs #3565 Fix compilation error after the rebase
Oct 19, 2018
ae2a1ef
Refs #3565 Fixed bug
Oct 19, 2018
64ad0ce
Refs #3565 Update Mock classes to remove references to FastCDR
Oct 19, 2018
b1ece43
Refs #3565. Fixed compilation errors.
richiware Oct 22, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
285 changes: 285 additions & 0 deletions examples/C++/Benchmark/DynamicTypesHelper.cpp

Large diffs are not rendered by default.

65 changes: 65 additions & 0 deletions examples/C++/Benchmark/DynamicTypesHelper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// 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 BenchMarkPublisher.h
*
*/

#ifndef DYNAMIC_TYPES_HELPER_H_
#define DYNAMIC_TYPES_HELPER_H_

#include <fastrtps/fastrtps_fwd.h>

namespace eprosima
{
namespace fastrtps
{
namespace types
{
class DynamicData;
class DynamicType_ptr;
}
}
}

class DynamicTypesHelper
{
public:
static eprosima::fastrtps::types::DynamicData* CreateSmallData();
static eprosima::fastrtps::types::DynamicData* CreateData();
static eprosima::fastrtps::types::DynamicData* CreateMediumData();
static eprosima::fastrtps::types::DynamicData* CreateBigData();
protected:

static eprosima::fastrtps::types::DynamicType_ptr GetMyMiniArrayType();
static eprosima::fastrtps::types::DynamicType_ptr GetBSAlias5Type();
static eprosima::fastrtps::types::DynamicType_ptr GetBasicStructType();
static eprosima::fastrtps::types::DynamicType_ptr GetMyOctetArray500Type();
static eprosima::fastrtps::types::DynamicType_ptr GetMySequenceLongType();
static eprosima::fastrtps::types::DynamicType_ptr GetMyEnumType();
static eprosima::fastrtps::types::DynamicType_ptr GetMyAliasEnumType();
static eprosima::fastrtps::types::DynamicType_ptr GetMA3Type();
static eprosima::fastrtps::types::DynamicType_ptr GetMyAliasEnum3Type();
static eprosima::fastrtps::types::DynamicType_ptr GetMyAliasEnum2Type();
static eprosima::fastrtps::types::DynamicType_ptr GetUnionSwitchType();
static eprosima::fastrtps::types::DynamicType_ptr GetUnion2SwitchType();
static eprosima::fastrtps::types::DynamicType_ptr GetComplexStructType();


};



#endif /* DYNAMIC_TYPES_HELPER_H_ */
51 changes: 51 additions & 0 deletions examples/C++/DynamicHelloWorldExample/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# 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.

cmake_minimum_required(VERSION 2.8.12)

if(NOT CMAKE_VERSION VERSION_LESS 3.0)
cmake_policy(SET CMP0048 NEW)
endif()

project(DynamicHelloWorldExample)

# Find requirements
if(NOT fastcdr_FOUND)
find_package(fastcdr REQUIRED)
endif()

if(NOT fastrtps_FOUND)
find_package(fastrtps REQUIRED)
endif()

# Set C++11
include(CheckCXXCompilerFlag)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG OR
CMAKE_CXX_COMPILER_ID MATCHES "Clang")
check_cxx_compiler_flag(-std=c++11 SUPPORTS_CXX11)
if(SUPPORTS_CXX11)
add_compile_options(-std=c++11)
else()
message(FATAL_ERROR "Compiler doesn't support C++11")
endif()
endif()

message(STATUS "Configuring HelloWorld example...")
file(GLOB HELLOWORLD_EXAMPLE_SOURCES_CXX "*.cxx")
file(GLOB HELLOWORLD_EXAMPLE_SOURCES_CPP "*.cpp")

add_executable(DynamicHelloWorldExample ${HELLOWORLD_EXAMPLE_SOURCES_CXX} ${HELLOWORLD_EXAMPLE_SOURCES_CPP})
target_link_libraries(DynamicHelloWorldExample fastrtps fastcdr)
install(TARGETS DynamicHelloWorldExample
RUNTIME DESTINATION examples/C++/DynamicHelloWorldExample/${BIN_INSTALL_DIR})
5 changes: 5 additions & 0 deletions examples/C++/DynamicHelloWorldExample/HelloWorld.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
struct HelloWorld
{
unsigned long index;
string message;
};
173 changes: 173 additions & 0 deletions examples/C++/DynamicHelloWorldExample/HelloWorldPublisher.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
// 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 HelloWorldPublisher.cpp
*
*/

#include "HelloWorldPublisher.h"
#include <fastrtps/attributes/ParticipantAttributes.h>
#include <fastrtps/attributes/PublisherAttributes.h>
#include <fastrtps/publisher/Publisher.h>
#include <fastrtps/Domain.h>
#include <fastrtps/utils/eClock.h>
#include <fastrtps/types/DynamicTypeBuilderFactory.h>
#include <fastrtps/types/DynamicDataFactory.h>
#include <fastrtps/types/DynamicTypeBuilder.h>
#include <fastrtps/types/DynamicTypeBuilderPtr.h>
#include <fastrtps/types/TypeDescriptor.h>
#include <fastrtps/types/MemberDescriptor.h>
#include <fastrtps/types/DynamicType.h>

using namespace eprosima::fastrtps;
using namespace eprosima::fastrtps::rtps;

HelloWorldPublisher::HelloWorldPublisher()
: mp_participant(nullptr)
, mp_publisher(nullptr)
, m_DynType(nullptr)
{
}

bool HelloWorldPublisher::init()
{
// Create basic builders
DynamicTypeBuilder_ptr struct_type_builder(DynamicTypeBuilderFactory::GetInstance()->CreateStructBuilder());

// Add members to the struct.
struct_type_builder->AddMember(0, "index", DynamicTypeBuilderFactory::GetInstance()->CreateUint32Type());
struct_type_builder->AddMember(1, "message", DynamicTypeBuilderFactory::GetInstance()->CreateStringType());
struct_type_builder->SetName("HelloWorld");

DynamicType_ptr dynType = struct_type_builder->Build();
m_DynType.SetDynamicType(dynType);
m_DynHello = DynamicDataFactory::GetInstance()->CreateData(dynType);
m_DynHello->SetUint32Value(0, 0);
m_DynHello->SetStringValue("HelloWorld", 1);

ParticipantAttributes PParam;
PParam.rtps.builtin.domainId = 0;
PParam.rtps.setName("DynHelloWorld_pub");
mp_participant = Domain::createParticipant(PParam, (ParticipantListener*)&m_part_list);

if(mp_participant==nullptr)
return false;

//REGISTER THE TYPE
Domain::registerDynamicType(mp_participant, &m_DynType);

//CREATE THE PUBLISHER
PublisherAttributes Wparam;
Wparam.topic.topicKind = NO_KEY;
Wparam.topic.topicDataType = "HelloWorld";
Wparam.topic.topicName = "HelloWorldTopic";
//Wparam.topic.topicDiscoveryKind = NO_CHECK; // Do it compatible with other HelloWorlds
mp_publisher = Domain::createPublisher(mp_participant,Wparam,(PublisherListener*)&m_listener);
if(mp_publisher == nullptr)
return false;

return true;

}

HelloWorldPublisher::~HelloWorldPublisher()
{
Domain::removeParticipant(mp_participant);

DynamicDataFactory::GetInstance()->DeleteData(m_DynHello);

Domain::stopAll();
}

void HelloWorldPublisher::PubListener::onPublicationMatched(Publisher* /*pub*/,MatchingInfo& info)
{
if(info.status == MATCHED_MATCHING)
{
n_matched++;
firstConnected = true;
std::cout << "Publisher matched"<<std::endl;
}
else
{
n_matched--;
std::cout << "Publisher unmatched"<<std::endl;
}
}

void HelloWorldPublisher::PartListener::onParticipantDiscovery(Participant*, ParticipantDiscoveryInfo info)
{
if (info.rtps.m_status == DISCOVERED_RTPSPARTICIPANT)
{
std::cout << "Participant " << info.rtps.m_RTPSParticipantName << " discovered" << std::endl;
}
else if (info.rtps.m_status == REMOVED_RTPSPARTICIPANT)
{
std::cout << "Participant removed" << std::endl;
}
else if (info.rtps.m_status == DROPPED_RTPSPARTICIPANT)
{
std::cout << "Participant " << info.rtps.m_RTPSParticipantName << " dropped" << std::endl;
}
}

void HelloWorldPublisher::runThread(uint32_t samples, uint32_t sleep)
{
uint32_t i = 0;

while(!stop && (i < samples || samples == 0))
{
if(publish(samples != 0))
{
std::string message;
m_DynHello->GetStringValue(message, 1);
uint32_t index;
m_DynHello->GetUint32Value(index, 0);

std::cout << "Message: " << message << " with index: " << index << " SENT" << std::endl;
++i;
}
eClock::my_sleep(sleep);
}
}

void HelloWorldPublisher::run(uint32_t samples, uint32_t sleep)
{
stop = false;
std::thread thread(&HelloWorldPublisher::runThread, this, samples, sleep);
if (samples == 0)
{
std::cout << "Publisher running. Please press enter to stop the Publisher at any time." << std::endl;
std::cin.ignore();
stop = true;
}
else
{
std::cout << "Publisher running " << samples << " samples." << std::endl;
}
thread.join();
}

bool HelloWorldPublisher::publish(bool waitForListener)
{
if(m_listener.firstConnected || !waitForListener || m_listener.n_matched>0)
{
uint32_t index;
m_DynHello->GetUint32Value(index, 0);
m_DynHello->SetUint32Value(index+1, 0);
mp_publisher->write((void*)m_DynHello);
return true;
}
return false;
}
69 changes: 69 additions & 0 deletions examples/C++/DynamicHelloWorldExample/HelloWorldPublisher.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// 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 HelloWorldPublisher.h
*
*/

#ifndef HELLOWORLDPUBLISHER_H_
#define HELLOWORLDPUBLISHER_H_

#include <fastrtps/fastrtps_fwd.h>
#include <fastrtps/attributes/PublisherAttributes.h>
#include <fastrtps/publisher/PublisherListener.h>
#include <fastrtps/participant/ParticipantListener.h>
#include <fastrtps/participant/Participant.h>
#include <fastrtps/types/DynamicData.h>
#include <fastrtps/types/DynamicPubSubType.h>


class HelloWorldPublisher {
public:
HelloWorldPublisher();
virtual ~HelloWorldPublisher();
//!Initialize
bool init();
//!Publish a sample
bool publish(bool waitForListener = true);
//!Run for number samples
void run(uint32_t number, uint32_t sleep);
private:
eprosima::fastrtps::Participant* mp_participant;
eprosima::fastrtps::Publisher* mp_publisher;
bool stop;
class PubListener:public eprosima::fastrtps::PublisherListener
{
public:
PubListener():n_matched(0),firstConnected(false){};
~PubListener(){};
void onPublicationMatched(eprosima::fastrtps::Publisher* pub, eprosima::fastrtps::rtps::MatchingInfo& info);
int n_matched;
bool firstConnected;
}m_listener;
class PartListener : public eprosima::fastrtps::ParticipantListener
{
void onParticipantDiscovery(eprosima::fastrtps::Participant* p,
eprosima::fastrtps::ParticipantDiscoveryInfo info) override;
}m_part_list;
void runThread(uint32_t number, uint32_t sleep);

// Dynamic Types
eprosima::fastrtps::types::DynamicData* m_DynHello;
eprosima::fastrtps::types::DynamicPubSubType m_DynType;
};



#endif /* HELLOWORLDPUBLISHER_H_ */
Loading