helics 3.7.0
Loading...
Searching...
No Matches
EndpointInfo.hpp
1/*
2Copyright (c) 2017-2026,
3Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance for Energy
4Innovation LLC. See the top-level NOTICE for additional details. All rights reserved.
5SPDX-License-Identifier: BSD-3-Clause
6*/
7#pragma once
8
9#include "../common/GuardedTypes.hpp"
10#include "basic_CoreTypes.hpp"
11
12#include <atomic>
13#include <deque>
14#include <memory>
15#include <string>
16#include <utility>
17#include <vector>
18
19namespace helics {
20
22 GlobalHandle id;
23 std::string key;
24 std::string type;
25 EndpointInformation() = default;
26 EndpointInformation(GlobalHandle gid, std::string_view key_, std::string_view type_):
27 id(gid), key(key_), type(type_)
28 {
29 }
30};
33 public:
35 EndpointInfo(GlobalHandle handle, std::string_view key_, std::string_view type_):
36 id(handle), key(key_), type(type_)
37 {
38 }
39
41 const std::string key;
42 const std::string type;
43 private:
46 std::atomic<int32_t> mAvailableMessages{0};
47
48 std::vector<EndpointInformation> sourceInformation;
49 std::vector<EndpointInformation> targetInformation;
50 std::vector<std::pair<GlobalHandle, std::string_view>> targets;
51 mutable std::string sourceTargets;
52 mutable std::string destinationTargets;
53
54 public:
55 bool hasFilter{false};
56 bool required{false};
57 bool targetedEndpoint{false};
58 bool sourceOnly{false};
59 bool receiveOnly{false};
62 std::unique_ptr<Message> getMessage(Time maxTime);
64 int32_t availableMessages() const;
66 int32_t queueSize(Time maxTime) const;
68 int32_t queueSizeUpTo(Time maxTime) const;
70 void addMessage(std::unique_ptr<Message> message);
75 bool updateTimeUpTo(Time newTime);
80 bool updateTimeInclusive(Time newTime);
81
83 bool hasConnection() const;
85 bool hasSource() const;
87 bool hasTarget() const;
92 bool updateTimeNextIteration(Time newTime);
94 Time firstMessageTime() const;
96 void clearQueue();
98 void addDestination(GlobalHandle dest, std::string_view destName, std::string_view destType);
100 void addSource(GlobalHandle source, std::string_view sourceName, std::string_view sourceType);
102 void removeTarget(GlobalHandle targetId);
104 void disconnectFederate(GlobalFederateId fedToDisconnect);
106 const std::vector<std::pair<GlobalHandle, std::string_view>>& getTargets() const
107 {
108 return targets;
109 }
111 const std::string& getSourceTargets() const;
113 const std::string& getDestinationTargets() const;
114
116 void checkInterfacesForIssues(std::vector<std::pair<int, std::string>>& issues);
117
118 void setProperty(int32_t option, int32_t value);
119 int32_t getProperty(int32_t option) const;
120};
121} // namespace helics
Definition application_api/Federate.hpp:27
Definition EndpointInfo.hpp:32
int32_t requiredConnections
an exact number of connections required
Definition EndpointInfo.hpp:60
bool receiveOnly
the endpoint can only receive data and cannot send
Definition EndpointInfo.hpp:59
const std::string type
type of the endpoint
Definition EndpointInfo.hpp:42
void disconnectFederate(GlobalFederateId fedToDisconnect)
Definition EndpointInfo.cpp:237
void addSource(GlobalHandle source, std::string_view sourceName, std::string_view sourceType)
Definition EndpointInfo.cpp:199
bool hasSource() const
Definition EndpointInfo.cpp:142
bool updateTimeNextIteration(Time newTime)
Definition EndpointInfo.cpp:44
void addDestination(GlobalHandle dest, std::string_view destName, std::string_view destType)
Definition EndpointInfo.cpp:180
bool sourceOnly
the endpoint can only be a source of data and cannot receive data
Definition EndpointInfo.hpp:58
bool hasFilter
indicator that the message has a filter
Definition EndpointInfo.hpp:55
int32_t queueSizeUpTo(Time maxTime) const
Definition EndpointInfo.cpp:166
bool updateTimeInclusive(Time newTime)
Definition EndpointInfo.cpp:65
bool updateTimeUpTo(Time newTime)
Definition EndpointInfo.cpp:23
void removeTarget(GlobalHandle targetId)
Definition EndpointInfo.cpp:212
const GlobalHandle id
identifier for the handle
Definition EndpointInfo.hpp:40
bool targetedEndpoint
indicator that the endpoint is a targeted endpoint only
Definition EndpointInfo.hpp:57
int32_t queueSize(Time maxTime) const
Definition EndpointInfo.cpp:152
void clearQueue()
Definition EndpointInfo.cpp:126
const std::string & getDestinationTargets() const
Definition EndpointInfo.cpp:281
void checkInterfacesForIssues(std::vector< std::pair< int, std::string > > &issues)
Definition EndpointInfo.cpp:300
const std::string & getSourceTargets() const
Definition EndpointInfo.cpp:262
int32_t availableMessages() const
Definition EndpointInfo.cpp:132
const std::vector< std::pair< GlobalHandle, std::string_view > > & getTargets() const
Definition EndpointInfo.hpp:106
EndpointInfo(GlobalHandle handle, std::string_view key_, std::string_view type_)
Definition EndpointInfo.hpp:35
bool hasConnection() const
Definition EndpointInfo.cpp:137
std::unique_ptr< Message > getMessage(Time maxTime)
Definition EndpointInfo.cpp:86
bool hasTarget() const
Definition EndpointInfo.cpp:147
Time firstMessageTime() const
Definition EndpointInfo.cpp:105
const std::string key
name of the endpoint
Definition EndpointInfo.hpp:41
void addMessage(std::unique_ptr< Message > message)
Definition EndpointInfo.cpp:119
Definition GlobalFederateId.hpp:75
Definition GlobalFederateId.hpp:147
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition AsyncFedCallInfo.hpp:14
TimeRepresentation< count_time< 9 > > Time
Definition helicsTime.hpp:27
Definition EndpointInfo.hpp:21