helics  2.8.1
EndpointInfo.hpp
1 /*
2 Copyright (c) 2017-2021,
3 Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance for Sustainable
4 Energy, LLC. See the top-level NOTICE for additional details. All rights reserved.
5 SPDX-License-Identifier: BSD-3-Clause
6 */
7 #pragma once
8 
9 #include "../common/GuardedTypes.hpp"
10 #include "basic_core_types.hpp"
11 
12 #include <atomic>
13 #include <deque>
14 #include <memory>
15 #include <string>
16 
17 namespace helics {
19 class EndpointInfo {
20  public:
22  EndpointInfo(global_handle handle, const std::string& key_, const std::string& type_):
23  id(handle), key(key_), type(type_)
24  {
25  }
26 
27  const global_handle id;
28  const std::string key;
29  const std::string type;
30  private:
32  message_queue;
33  std::atomic<int32_t> mAvailableMessages{0};
34 
35  public:
36  bool hasFilter{false};
37  bool required{false};
39  std::unique_ptr<Message> getMessage(Time maxTime);
41  int32_t availableMessages() const;
43  int32_t queueSize(Time maxTime) const;
45  int32_t queueSizeUpTo(Time maxTime) const;
47  void addMessage(std::unique_ptr<Message> message);
52  bool updateTimeUpTo(Time newTime);
57  bool updateTimeInclusive(Time newTime);
58 
63  bool updateTimeNextIteration(Time newTime);
65  Time firstMessageTime() const;
67  void clearQueue();
68 };
69 } // namespace helics
helics::EndpointInfo::id
const global_handle id
identifier for the handle
Definition: EndpointInfo.hpp:27
helics::EndpointInfo::updateTimeUpTo
bool updateTimeUpTo(Time newTime)
Definition: EndpointInfo.cpp:17
helics::EndpointInfo::queueSize
int32_t queueSize(Time maxTime) const
Definition: EndpointInfo.cpp:130
helics::EndpointInfo
Definition: EndpointInfo.hpp:19
helics::Time
TimeRepresentation< count_time< 9 > > Time
Definition: helics-time.hpp:27
helics::EndpointInfo::EndpointInfo
EndpointInfo(global_handle handle, const std::string &key_, const std::string &type_)
Definition: EndpointInfo.hpp:22
helics::EndpointInfo::queueSizeUpTo
int32_t queueSizeUpTo(Time maxTime) const
Definition: EndpointInfo.cpp:144
helics::global_handle
Definition: global_federate_id.hpp:128
helics::EndpointInfo::getMessage
std::unique_ptr< Message > getMessage(Time maxTime)
Definition: EndpointInfo.cpp:80
helics::EndpointInfo::hasFilter
bool hasFilter
indicator that the message has a filter
Definition: EndpointInfo.hpp:36
helics::EndpointInfo::key
const std::string key
name of the endpoint
Definition: EndpointInfo.hpp:28
helics::EndpointInfo::clearQueue
void clearQueue()
Definition: EndpointInfo.cpp:119
helics::EndpointInfo::type
const std::string type
type of the endpoint
Definition: EndpointInfo.hpp:29
helics::EndpointInfo::firstMessageTime
Time firstMessageTime() const
Definition: EndpointInfo.cpp:99
helics
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
helics::EndpointInfo::addMessage
void addMessage(std::unique_ptr< Message > message)
Definition: EndpointInfo.cpp:112
helics::EndpointInfo::updateTimeNextIteration
bool updateTimeNextIteration(Time newTime)
Definition: EndpointInfo.cpp:38
gmlc::libguarded::shared_guarded
Definition: application_api/Federate.hpp:26
helics::EndpointInfo::availableMessages
int32_t availableMessages() const
Definition: EndpointInfo.cpp:125
helics::EndpointInfo::updateTimeInclusive
bool updateTimeInclusive(Time newTime)
Definition: EndpointInfo.cpp:59