Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 2, 2024
1 parent ba7cdfe commit 0bcd855
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 240 deletions.
3 changes: 2 additions & 1 deletion src/helics/apps/helicsApp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ necessary
const CombinationFederate& accessUnderlyingFederate() const { return *fed; }

/** get a copy of the federate pointer (this can be dangerous if misused) */
std::shared_ptr<CombinationFederate> getUnderlyingFederatePointer() {return fed;}
std::shared_ptr<CombinationFederate> getUnderlyingFederatePointer() { return fed; }

protected:
/** load from a jsonString
@param jsonString either a JSON filename or a string containing JSON
Expand Down
4 changes: 2 additions & 2 deletions src/helics/helics_apps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ Header file for inclusion of the entire apps library
#pragma once

#include "apps/BrokerApp.hpp"
#include "apps/Clone.hpp"
#include "apps/Connector.hpp"
#include "apps/Echo.hpp"
#include "apps/Player.hpp"
#include "apps/Probe.hpp"
#include "apps/Recorder.hpp"
#include "apps/Source.hpp"
#include "apps/Tracer.hpp"
#include "apps/Probe.hpp"
#include "apps/Clone.hpp"
31 changes: 15 additions & 16 deletions src/helics/shared_api_library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ set(helicsShared_sources
internal/api_objects.h
)


if (TARGET HELICS::apps)
if(TARGET HELICS::apps)
list(APPEND helicsShared_sources helicsAppsExport.cpp)
else()
list(APPEND helicsShared_sources helicsAppsExportNull.cpp)
Expand Down Expand Up @@ -118,7 +117,7 @@ set_target_properties(helics PROPERTIES VERSION ${HELICS_VERSION} SOVERSION ${HE

set_target_properties(helics PROPERTIES CXX_VISIBILITY_PRESET hidden C_VISIBILITY_PRESET hidden)
target_link_libraries(helics PRIVATE helics_application_api)
if (TARGET HELICS::apps)
if(TARGET HELICS::apps)
target_link_libraries(helics PRIVATE HELICS::apps)
endif()
target_link_libraries(helics PRIVATE compile_flags_target)
Expand All @@ -129,20 +128,20 @@ endif()

if(UNIX OR MINGW)
if(NOT APPLE)
include(CheckLinkerFlag)
check_linker_flag(
CXX "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/export.txt"
flag_linker_version_script
include(CheckLinkerFlag)
check_linker_flag(
CXX "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/export.txt"
flag_linker_version_script
)
if(flag_linker_version_script)
target_link_libraries(
helics PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/export.txt
)
if(flag_linker_version_script)
target_link_libraries(
helics PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/export.txt
)
endif()
check_linker_flag(CXX "-Wl,--exclude-libs,ALL" flag_linker_exclude_libs)
if(flag_linker_exclude_libs)
target_link_libraries(helics PRIVATE -Wl,--exclude-libs,ALL)
endif()
endif()
check_linker_flag(CXX "-Wl,--exclude-libs,ALL" flag_linker_exclude_libs)
if(flag_linker_exclude_libs)
target_link_libraries(helics PRIVATE -Wl,--exclude-libs,ALL)
endif()
else(NOT_APPLE)
target_link_libraries(
helics PRIVATE -Wl,-exported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/export_mac.txt
Expand Down
37 changes: 18 additions & 19 deletions src/helics/shared_api_library/FederateExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,12 +457,11 @@ void helicsFederateInfoSetIntegerProperty(HelicsFederateInfo fedInfo, int intege
info->setProperty(integerProperty, propertyValue);
}


HelicsFederate generateNewHelicsFederateObject(std::shared_ptr<helics::Federate> fed,helics::FederateType type)
HelicsFederate generateNewHelicsFederateObject(std::shared_ptr<helics::Federate> fed, helics::FederateType type)
{
auto fedI = std::make_unique<helics::FedObject>();
fedI->fedptr=fed;
fedI->type=type;
fedI->fedptr = fed;
fedI->type = type;
fedI->valid = fedValidationIdentifier;
auto* hfed = reinterpret_cast<HelicsFederate>(fedI.get());
getMasterHolder()->addFed(std::move(fedI));
Expand All @@ -473,24 +472,24 @@ HelicsFederate generateNewHelicsFederateObject(std::shared_ptr<helics::Federate>
HelicsFederate helicsCreateValueFederate(const char* fedName, HelicsFederateInfo fedInfo, HelicsError* err)
{
HELICS_ERROR_CHECK(err, nullptr);

std::shared_ptr<helics::Federate> fed;
try {
if (fedInfo == nullptr) {
fed=std::make_shared<helics::ValueFederate>(AS_STRING(fedName), helics::FederateInfo());
fed = std::make_shared<helics::ValueFederate>(AS_STRING(fedName), helics::FederateInfo());
} else {
auto* info = getFedInfo(fedInfo, err);
if (info == nullptr) {
return nullptr;
}
fed=std::make_shared<helics::ValueFederate>(AS_STRING(fedName), *info);
fed = std::make_shared<helics::ValueFederate>(AS_STRING(fedName), *info);
}
}
catch (...) {
helicsErrorHandler(err);
return nullptr;
}
return generateNewHelicsFederateObject(std::move(fed),helics::FederateType::VALUE);
return generateNewHelicsFederateObject(std::move(fed), helics::FederateType::VALUE);
}

HelicsFederate helicsCreateValueFederateFromConfig(const char* configFile, HelicsError* err)
Expand All @@ -504,7 +503,7 @@ HelicsFederate helicsCreateValueFederateFromConfig(const char* configFile, Helic
helicsErrorHandler(err);
return nullptr;
}
return generateNewHelicsFederateObject(std::move(fed),helics::FederateType::VALUE);
return generateNewHelicsFederateObject(std::move(fed), helics::FederateType::VALUE);
}

/* Creation and destruction of Federates */
Expand All @@ -527,7 +526,7 @@ HelicsFederate helicsCreateMessageFederate(const char* fedName, HelicsFederateIn
helicsErrorHandler(err);
return nullptr;
}
return generateNewHelicsFederateObject(std::move(fed),helics::FederateType::MESSAGE);
return generateNewHelicsFederateObject(std::move(fed), helics::FederateType::MESSAGE);
}

HelicsFederate helicsCreateMessageFederateFromConfig(const char* configFile, HelicsError* err)
Expand All @@ -542,7 +541,7 @@ HelicsFederate helicsCreateMessageFederateFromConfig(const char* configFile, Hel
helicsErrorHandler(err);
return nullptr;
}
return generateNewHelicsFederateObject(std::move(fed),helics::FederateType::MESSAGE);
return generateNewHelicsFederateObject(std::move(fed), helics::FederateType::MESSAGE);
}

/* Creation and destruction of Federates */
Expand All @@ -558,14 +557,14 @@ HelicsFederate helicsCreateCombinationFederate(const char* fedName, HelicsFedera
if (info == nullptr) {
return nullptr;
}
fed = std::make_shared<helics::CombinationFederate>(AS_STRING(fedName), *info);
fed = std::make_shared<helics::CombinationFederate>(AS_STRING(fedName), *info);
}
}
catch (...) {
helicsErrorHandler(err);
return nullptr;
}
return generateNewHelicsFederateObject(std::move(fed),helics::FederateType::COMBINATION);
return generateNewHelicsFederateObject(std::move(fed), helics::FederateType::COMBINATION);
}

HelicsFederate helicsCreateCombinationFederateFromConfig(const char* configFile, HelicsError* err)
Expand All @@ -580,7 +579,7 @@ HelicsFederate helicsCreateCombinationFederateFromConfig(const char* configFile,
return nullptr;
}

return generateNewHelicsFederateObject(std::move(fed),helics::FederateType::COMBINATION);
return generateNewHelicsFederateObject(std::move(fed), helics::FederateType::COMBINATION);
}

/* Creation and destruction of Federates */
Expand All @@ -596,14 +595,14 @@ HelicsFederate helicsCreateCallbackFederate(const char* fedName, HelicsFederateI
if (info == nullptr) {
return nullptr;
}
fed= std::make_shared<helics::CallbackFederate>(AS_STRING(fedName), *info);
fed = std::make_shared<helics::CallbackFederate>(AS_STRING(fedName), *info);
}
}
catch (...) {
helicsErrorHandler(err);
return nullptr;
}
return generateNewHelicsFederateObject(std::move(fed),helics::FederateType::CALLBACK);
return generateNewHelicsFederateObject(std::move(fed), helics::FederateType::CALLBACK);
}

HelicsFederate helicsCreateCallbackFederateFromConfig(const char* configFile, HelicsError* err)
Expand All @@ -618,7 +617,7 @@ HelicsFederate helicsCreateCallbackFederateFromConfig(const char* configFile, He
return nullptr;
}

return generateNewHelicsFederateObject(std::move(fed),helics::FederateType::CALLBACK);
return generateNewHelicsFederateObject(std::move(fed), helics::FederateType::CALLBACK);
}

HelicsFederate helicsFederateClone(HelicsFederate fed, HelicsError* err)
Expand All @@ -627,7 +626,7 @@ HelicsFederate helicsFederateClone(HelicsFederate fed, HelicsError* err)
if (fedObj == nullptr) {
return nullptr;
}
return generateNewHelicsFederateObject(fedObj->fedptr,fedObj->type);
return generateNewHelicsFederateObject(fedObj->fedptr, fedObj->type);
}

HelicsFederate helicsGetFederateByName(const char* fedName, HelicsError* err)
Expand All @@ -651,7 +650,7 @@ HelicsFederate helicsGetFederateByName(const char* fedName, HelicsError* err)
}
return nullptr;
}
return generateNewHelicsFederateObject(fed->fedptr,fed->type);
return generateNewHelicsFederateObject(fed->fedptr, fed->type);
}

void helicsFederateProtect(const char* fedName, HelicsError* err)
Expand Down
4 changes: 2 additions & 2 deletions src/helics/shared_api_library/api-data.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ typedef void* HelicsBroker;
typedef void* HelicsFederate;

/**
* opaque object representing a helics app
*/
* opaque object representing a helics app
*/
// typedef void* helics_federate;
typedef void* HelicsApp;

Expand Down
154 changes: 76 additions & 78 deletions src/helics/shared_api_library/helicsApps.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ SPDX-License-Identifier: BSD-3-Clause
*/

/**
* @file
* @brief Functions related to using helics apps
*/
* @file
* @brief Functions related to using helics apps
*/

#ifndef HELICS_APISHARED_APP_FUNCTIONS_H_
#define HELICS_APISHARED_APP_FUNCTIONS_H_
Expand All @@ -19,81 +19,79 @@ SPDX-License-Identifier: BSD-3-Clause
extern "C" {
#endif

/**
* Create a helics app object
*
* @details create a helics App object
*
* @param appName A string with the name of the app, can be NULL or an empty string to pull the default name from fedInfo or the config file.
* @param appType the type of app to create
* @param configFile configuration file or string to pass into the app, can be NULL or empty
* @param fedInfo the federate information to pass into the app, can be NULL
* @param[in,out] err An error object that will contain an error code and string if any error occurred during the execution of the function.
*
* @return An opaque value app object nullptr if the object creation failed.
*/
HELICS_EXPORT HelicsApp helicsCreateApp(const char* appName, const char *appType, const char *configFile, HelicsFederateInfo fedInfo, HelicsError* err);

/** run the App
* @details execute the app to completion
* @param app the app to execute
* @param[in,out] err An error object that will contain an error code and string if any error occurred during the execution of the function.
*
* @return An opaque value federate object that can be used in any of the federate methods, not recommended to use this object to advance time, the app will not likely function
normally, other query, or information calls, or modification calls on the federate are fine.
*/
HELICS_EXPORT HelicsFederate helicsAppGetFederate(HelicsApp app,HelicsError* err);

/**
* Create a helics app object
*
* @details create a helics App object
*
* @param appName A string with the name of the app, can be NULL or an empty string to pull the default name from fedInfo or the config file.
* @param appType the type of app to create
* @param configFile configuration file or string to pass into the app, can be NULL or empty
* @param fedInfo the federate information to pass into the app, can be NULL
* @param[in,out] err An error object that will contain an error code and string if any error occurred during the execution of the function.
*
* @return An opaque value app object nullptr if the object creation failed.
*/
HELICS_EXPORT void helicsAppLoadFile(HelicsApp app, const char *configFile, HelicsError* err);

/** initialize the App federate
* @details generate all the interfaces and load data for the application
* @param app the app to initialize
* @param[in,out] err An error object that will contain an error code and string if any error occurred during the execution of the function.
*/
HELICS_EXPORT void helicsAppInitialize(HelicsApp app, HelicsError* err);


/** run the App
* @details execute the app to completion
* @param app the app to execute
* @param[in,out] err An error object that will contain an error code and string if any error occurred during the execution of the function.
*/
HELICS_EXPORT void helicsAppRun(HelicsApp app, HelicsError* err);


/** run and app to a specified stop time
* @details it is possible to call this method repeatedly with different times
* @param app the app to run
* @param stopTime the desired stop time
* @param[in,out] err An error object that will contain an error code and string if any error occurred during the execution of the function.
*/
HELICS_EXPORT void helicsAppRunTo(HelicsApp app, HelicsTime stopTime, HelicsError* err);


/** finalize the app
* @param app the app to execute
* @param[in,out] err An error object that will contain an error code and string if any error occurred during the execution of the function.
*/
HELICS_EXPORT void helicsAppFinalize(HelicsApp app, HelicsError* err);

/** check if the App is ready to run*/
HELICS_EXPORT HelicsBool helicsAppIsActive(HelicsApp app);
/**
* Create a helics app object
*
* @details create a helics App object
*
* @param appName A string with the name of the app, can be NULL or an empty string to pull the default name from fedInfo or the config file.
* @param appType the type of app to create
* @param configFile configuration file or string to pass into the app, can be NULL or empty
* @param fedInfo the federate information to pass into the app, can be NULL
* @param[in,out] err An error object that will contain an error code and string if any error occurred during the execution of the function.
*
* @return An opaque value app object nullptr if the object creation failed.
*/
HELICS_EXPORT HelicsApp
helicsCreateApp(const char* appName, const char* appType, const char* configFile, HelicsFederateInfo fedInfo, HelicsError* err);

/** run the App
* @details execute the app to completion
* @param app the app to execute
* @param[in,out] err An error object that will contain an error code and string if any error occurred during the execution of the function.
*
* @return An opaque value federate object that can be used in any of the federate methods, not recommended to use this object to advance
time, the app will not likely function normally, other query, or information calls, or modification calls on the federate are fine.
*/
HELICS_EXPORT HelicsFederate helicsAppGetFederate(HelicsApp app, HelicsError* err);

/**
* Create a helics app object
*
* @details create a helics App object
*
* @param appName A string with the name of the app, can be NULL or an empty string to pull the default name from fedInfo or the config file.
* @param appType the type of app to create
* @param configFile configuration file or string to pass into the app, can be NULL or empty
* @param fedInfo the federate information to pass into the app, can be NULL
* @param[in,out] err An error object that will contain an error code and string if any error occurred during the execution of the function.
*
* @return An opaque value app object nullptr if the object creation failed.
*/
HELICS_EXPORT void helicsAppLoadFile(HelicsApp app, const char* configFile, HelicsError* err);

/** initialize the App federate
* @details generate all the interfaces and load data for the application
* @param app the app to initialize
* @param[in,out] err An error object that will contain an error code and string if any error occurred during the execution of the function.
*/
HELICS_EXPORT void helicsAppInitialize(HelicsApp app, HelicsError* err);

/** run the App
* @details execute the app to completion
* @param app the app to execute
* @param[in,out] err An error object that will contain an error code and string if any error occurred during the execution of the function.
*/
HELICS_EXPORT void helicsAppRun(HelicsApp app, HelicsError* err);

/** run and app to a specified stop time
* @details it is possible to call this method repeatedly with different times
* @param app the app to run
* @param stopTime the desired stop time
* @param[in,out] err An error object that will contain an error code and string if any error occurred during the execution of the function.
*/
HELICS_EXPORT void helicsAppRunTo(HelicsApp app, HelicsTime stopTime, HelicsError* err);

/** finalize the app
* @param app the app to execute
* @param[in,out] err An error object that will contain an error code and string if any error occurred during the execution of the function.
*/
HELICS_EXPORT void helicsAppFinalize(HelicsApp app, HelicsError* err);

/** check if the App is ready to run*/
HELICS_EXPORT HelicsBool helicsAppIsActive(HelicsApp app);

#ifdef __cplusplus
} /* end of extern "C" { */
Expand Down
Loading

0 comments on commit 0bcd855

Please sign in to comment.