-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt example generation to Fast DDS examples refactor (#377)
* Refs #21324: Adapt example generation to Fast DDS examples refactor Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com> * Refs #21324: Apply rev suggestions Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com> * Refs #21324: Add missing includes to build on windows Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com> --------- Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
- Loading branch information
1 parent
fa5ad77
commit 78da8ab
Showing
8 changed files
with
457 additions
and
266 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
49 changes: 49 additions & 0 deletions
49
src/main/java/com/eprosima/fastdds/idl/templates/DDSApplicationHeader.stg
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,49 @@ | ||
// Copyright 2024 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. | ||
|
||
group ProtocolHeader; | ||
|
||
import "eprosima.stg" | ||
|
||
main(ctx, definitions) ::= << | ||
$fileHeader(ctx=ctx, file=[ctx.filename, "Application.hpp"], description=["This header file contains the declaration of the application functions."])$ | ||
|
||
#ifndef FAST_DDS_GENERATED__$ctx.headerGuardName$APPLICATION_HPP | ||
#define FAST_DDS_GENERATED__$ctx.headerGuardName$APPLICATION_HPP | ||
|
||
#include <atomic> | ||
#include <memory> | ||
#include <string> | ||
|
||
class $ctx.filename$Application | ||
{ | ||
public: | ||
|
||
//! Virtual destructor | ||
virtual ~$ctx.filename$Application() = default; | ||
|
||
//! Run application | ||
virtual void run() = 0; | ||
|
||
//! Trigger the end of execution | ||
virtual void stop() = 0; | ||
|
||
//! Factory method to create applications based on configuration | ||
static std::shared_ptr<$ctx.filename$Application> make_app( | ||
const int& domain_id, | ||
const std::string& entity_kind); | ||
}; | ||
|
||
#endif // FAST_DDS_GENERATED__$ctx.headerGuardName$APPLICATION_HPP | ||
>> |
47 changes: 47 additions & 0 deletions
47
src/main/java/com/eprosima/fastdds/idl/templates/DDSApplicationSource.stg
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,47 @@ | ||
// Copyright 2024 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. | ||
|
||
group ProtocolHeader; | ||
|
||
import "eprosima.stg" | ||
|
||
main(ctx, definitions) ::= << | ||
$fileHeader(ctx=ctx, file=[ctx.filename, "Application.cxx"], description=["This file contains the implementation of the application functions."])$ | ||
|
||
#include "$ctx.filename$Application.hpp" | ||
|
||
#include "$ctx.filename$PublisherApp.hpp" | ||
#include "$ctx.filename$SubscriberApp.hpp" | ||
|
||
//! Factory method to create a publisher or subscriber | ||
std::shared_ptr<$ctx.filename$Application> $ctx.filename$Application::make_app( | ||
const int& domain_id, | ||
const std::string& entity_kind) | ||
{ | ||
std::shared_ptr<$ctx.filename$Application> entity; | ||
if (strcmp(entity_kind.c_str(), "publisher") == 0) | ||
{ | ||
entity = std::make_shared<$ctx.filename$PublisherApp>(domain_id); | ||
} | ||
else if (strcmp(entity_kind.c_str(), "subscriber") == 0) | ||
{ | ||
entity = std::make_shared<$ctx.filename$SubscriberApp>(domain_id); | ||
} | ||
else | ||
{ | ||
throw std::runtime_error("Entity initialization failed"); | ||
} | ||
return entity; | ||
} | ||
>> |
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
Oops, something went wrong.