Skip to content

Commit

Permalink
fix some clang-tidy issues and update backup header files (#2634)
Browse files Browse the repository at this point in the history
* fix some clang-tidy issues and update backup header files

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update CHANGELOG.md

Co-authored-by: Ryan Mast <[email protected]>

* fix some clang-tidy issues and update backup header files


---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ryan Mast <[email protected]>
  • Loading branch information
3 people authored Mar 19, 2024
1 parent 9c7136c commit f75d624
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 26 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
A note on future revisions.
Everything within a major version number should be code compatible (with the exception of experimental interfaces). The most notable example of an experimental interface is the support for multiple source inputs. The APIs to deal with this will change in future minor releases. Everything within a single minor release should be network compatible with other federates on the same minor release number. Compatibility across minor release numbers may be possible in some situations but we are not going to guarantee this as those components are subject to performance improvements and may need to be modified at some point. Patch releases will be limited to bug fixes and other improvements not impacting the public API or network compatibility. Check the [Public API](./docs/Public_API.md) for details on what is included and excluded from the public API and version stability.

## [3.5.1][] - 2024-03-16
## [3.5.1][] - 2024-03-19

Patch release including beta version of reentrant federates and support for "potential_interfaces" section in config files and automatic handling of potential interface generation in the federate class for operation with the connector app.

### Fixed

- Fixed an issue related to disconnection of federates with endpoints while still executing, that could potentially have resulted in an infinite loop
- Fixed an issue with aliases potentially causing a seg fault or memory condition, now aliases have reciprocity so order in the given alias call doesn't matter

### Changed

Expand Down Expand Up @@ -433,3 +434,5 @@ HELICS 3.0 is a major update to HELICS. The major features that have been added
[3.3.1]: https://github.com/GMLC-TDC/HELICS/releases/tag/v3.3.1
[3.3.2]: https://github.com/GMLC-TDC/HELICS/releases/tag/v3.3.2
[3.4.0]: https://github.com/GMLC-TDC/HELICS/releases/tag/v3.4.0
[3.5.0]: https://github.com/GMLC-TDC/HELICS/releases/tag/v3.5.0
[3.5.1]: https://github.com/GMLC-TDC/HELICS/releases/tag/v3.5.1
9 changes: 5 additions & 4 deletions docs/user-guide/advanced_topics/connector_fed.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,24 @@ To support this HELICS comes with a connector application called "helics_connect

## "helics_connector" Federate

The role of the "helics_connector" federate is to evaluate a mapping of the connections between federate interfaces and create the connections between these interfaces. Under the hood, it's using public APIs that allow the sources ("targets") for inputs and endpoints to be defined and destinations ("targets") to be added to publications. (Which is to say, if the stock "helics_connector" federate doesn't work the way you would like, you could actually make your own.) The documentation of the "helics_connector" app can be found on its [dedicated documentation page](TODO) but I'll summarize the highlights here:
The role of the "helics_connector" federate is to evaluate a mapping of the connections between federate interfaces and create the connections between these interfaces. Under the hood, it's using public APIs that allow the sources ("targets") for inputs and endpoints to be defined and destinations ("targets") to be added to publications. (Which is to say, if the stock "helics_connector" federate doesn't work the way you would like, you could actually make your own.) The documentation of the "helics_connector" app can be found on its [dedicated documentation page](../../references/apps/Connector.md) but I'll summarize the highlights here:

- Matches are defined in a plain text or JSON structured text file.
- Matches can be defined as one-to-one connections or use regular expressions to match many interfaces in one succinct line.
- Tags can be used to add an extra dimension to the matching process, only allowing federates with certain tags to be have their interfaces be candidates for the matching process.
- If federates support it, the connector can query a federate about the interfaces it could make and then, based on the results of the matching operation, command said federate to create the necessary interfaces.
- Potential interfaces can be defined in a json configuration file given to a federate. This can include interface templates to automatically generate a number of interfaces

## Callback Complications

The "query-and-command" form of operation is the most complex, largely because it requires the implementation of callback functions. Unless you're using the C API directly, implementing the callback functions takes a little bit of extra effort to get the C-based libraries under the hood working. Since most of the User Guide examples are in Python and most of our users are using Python, we've [documented callbacks in PyHELICS](TODO). Take a look at that page for further details to get a slightly better understanding why C-based callbacks are more complicated in Python.
The "query-and-command" form of operation is the most complex, largely because it requires the implementation of callback functions. Unless you're using the C API directly, implementing the callback functions takes a little bit of extra effort to get the C-based libraries under the hood working. Since most of the User Guide examples are in Python and most of our users are using Python, we've [documented callbacks in PyHELICS](TODO). Take a look at that page for further details to get a slightly better understanding why C-based callbacks are more complicated in Python. The better approach as of Version 3.5.1 is to use the `potential interfaces` section, then the callbacks for queries and interface generation are handled automatically by the helics federate.

## "helics_connector" Interface creation

The order in which "helics*connector" creates the interfaces in the federate is not deterministic. This is especially important when using the APIs that get the interface by index (\_e.g* `helicsFederateGetInputByIndex)`, `helicsFederateGetPublicationByIndex`, `helicsFederateGetEndpointByIndex`, `helicsFederateGetEndpointByIndex`). There is no guarantee that the order the interfaces are added to the federate will be the same from computer to computer. To continue using this API
The order in which "helics*connector" specified the needed interfaces in the federate is not deterministic. This is especially important when using the APIs that get the interface by index (\_e.g* `helicsFederateGetInputByIndex)`, `helicsFederateGetPublicationByIndex`, `helicsFederateGetEndpointByIndex`, `helicsFederateGetEndpointByIndex`). There is no guarantee that the order the interfaces are added to the federate will be the same from computer to computer. To continue using this API the name should be queried then potentially reordered or use the `ByName` version of the calls.

## Examples

Three examples have been created to demonstrate the use of the "helics_connector" federate: one uses a direct match-file, one uses a regex match-file and the the last uses a direct match-file while using the query-and-command method of interface creation. Links to the examples are provided below; all produce identical results.

An example utilizing both kinds of iteration is available in [here](../examples/advanced_examples/advanced_iteration.md)
An example utilizing both kinds of iteration will be developed shortly. Iteration example is available in [here](../examples/advanced_examples/advanced_iteration.md)
16 changes: 9 additions & 7 deletions src/helics/application_api/CallbackFederate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,23 @@ CallbackFederate::CallbackFederate() {}
// NOTE: the CallbackFederate must call the federate constructor do to the virtual inheritance in
// CombinationFederate

CallbackFederate::CallbackFederate(std::string_view fedName, const FederateInfo& fi):
Federate(fedName, fi), CombinationFederate(fedName, fi)
CallbackFederate::CallbackFederate(std::string_view fedName, const FederateInfo& fedInfo):
Federate(fedName, fedInfo), CombinationFederate(fedName, fedInfo)
{
loadOperator();
}
CallbackFederate::CallbackFederate(std::string_view fedName,
const std::shared_ptr<Core>& core,
const FederateInfo& fi):
Federate(fedName, core, fi), CombinationFederate(fedName, core, fi)
const FederateInfo& fedInfo):
Federate(fedName, core, fedInfo), CombinationFederate(fedName, core, fedInfo)
{
loadOperator();
}

CallbackFederate::CallbackFederate(std::string_view fedName, CoreApp& core, const FederateInfo& fi):
Federate(fedName, core, fi), CombinationFederate(fedName, core, fi)
CallbackFederate::CallbackFederate(std::string_view fedName,
CoreApp& core,
const FederateInfo& fedInfo):
Federate(fedName, core, fedInfo), CombinationFederate(fedName, core, fedInfo)
{
loadOperator();
}
Expand Down Expand Up @@ -132,7 +134,7 @@ void CallbackFederate::setFlagOption(int32_t property, bool val)
mEventTriggered = val;
// this does need to fallthrough
}
Federate::setFlagOption(property, val);
CombinationFederate::setFlagOption(property, val);
}

void CallbackFederate::finalizeCallback()
Expand Down
6 changes: 3 additions & 3 deletions src/helics/application_api/CallbackFederate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class HELICS_CXX_EXPORT CallbackFederate: public CombinationFederate {
@param fedName the name of the federate, may be left empty to use a default or one found in fi
@param fi a federate information structure
*/
explicit CallbackFederate(std::string_view fedName, const FederateInfo& fi);
explicit CallbackFederate(std::string_view fedName, const FederateInfo& fedInfo);

/**constructor taking a federate information structure and using the given core
@param fedName the name of the federate, may be left empty to use a default or one found in fi
Expand All @@ -34,7 +34,7 @@ class HELICS_CXX_EXPORT CallbackFederate: public CombinationFederate {
*/
CallbackFederate(std::string_view fedName,
const std::shared_ptr<Core>& core,
const FederateInfo& fi = FederateInfo{});
const FederateInfo& fedInfo = FederateInfo{});

/**constructor taking a federate information structure and using the given CoreApp
@param fedName the name of the federate, may be left empty to use a default or one found in fi
Expand All @@ -43,7 +43,7 @@ class HELICS_CXX_EXPORT CallbackFederate: public CombinationFederate {
*/
CallbackFederate(std::string_view fedName,
CoreApp& core,
const FederateInfo& fi = FederateInfo{});
const FederateInfo& fedInfo = FederateInfo{});

/**constructor taking a federate name and a file with the required information
@param fedName the name of the federate, can be empty to use the name from the configString
Expand Down
4 changes: 2 additions & 2 deletions src/helics/application_api/CombinationFederate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ SPDX-License-Identifier: BSD-3-Clause

namespace helics {
CombinationFederate::CombinationFederate() = default;
CombinationFederate::CombinationFederate(std::string_view fedName, const FederateInfo& fi):
Federate(fedName, fi), ValueFederate(true), MessageFederate(true)
CombinationFederate::CombinationFederate(std::string_view fedName, const FederateInfo& fedInfo):
Federate(fedName, fedInfo), ValueFederate(true), MessageFederate(true)
{
}
CombinationFederate::CombinationFederate(std::string_view fedName,
Expand Down
10 changes: 5 additions & 5 deletions src/helics/application_api/ConnectorFederateManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ Filter& ConnectorFederateManager::registerFilter(std::string_view name,
{
auto handle = coreObject->registerFilter(name, type_in, type_out);
if (handle.isValid()) {
auto filt = std::make_unique<Filter>(fed, name, handle);
Filter& f = *filt;
auto filtPtr = std::make_unique<Filter>(fed, name, handle);
Filter& filt = *filtPtr;
auto filts = filters.lock();
if (name.empty()) {
filts->insert(coreObject->getHandleName(filt->getHandle()), std::move(filt));
filts->insert(coreObject->getHandleName(filtPtr->getHandle()), std::move(filtPtr));
} else {
filts->insert(name, std::move(filt));
filts->insert(name, std::move(filtPtr));
}
return f;
return filt;
}
throw(RegistrationFailure("Unable to register Filter"));
}
Expand Down
8 changes: 4 additions & 4 deletions src/helics/application_api/ConnectorFederateManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ class ConnectorFederateManager {
/** register a Translator
@details call is only valid in startup mode
@param name the name of the translator
@param type_in the type the translator is expecting on the value interface
@param type_out the type the translator for the endpoint
@param endpointType is the type of the endpoints
@param units is the units associated with the value interface
*/
Translator& registerTranslator(std::string_view name,
std::string_view type_in,
std::string_view type_out);
std::string_view endpointType,
std::string_view units);

/** get a registered Translator
@param name the translator name
Expand Down

0 comments on commit f75d624

Please sign in to comment.