MADARA  3.4.1
LegacyBarrier.h
Go to the documentation of this file.
1 
2 #ifndef _MADARA_CONTAINERS_LEGACY_BARRIER_H_
3 #define _MADARA_CONTAINERS_LEGACY_BARRIER_H_
4 
5 #include <vector>
6 #include <string>
7 #include "madara/LockType.h"
11 #include "BaseContainer.h"
12 
21 namespace madara
22 {
23 namespace knowledge
24 {
25 namespace containers
26 {
31 class MADARA_EXPORT LegacyBarrier : public BaseContainer
32 {
33 public:
36 
41 
50 
59 
68  LegacyBarrier(const std::string& name, KnowledgeBase& knowledge, int id,
69  int participants,
71 
80  LegacyBarrier(const std::string& name, Variables& knowledge, int id,
81  int participants,
83 
87  LegacyBarrier(const LegacyBarrier& rhs);
88 
92  ~LegacyBarrier();
93 
98  void operator=(const LegacyBarrier& rhs);
99 
104  size_t get_id(void) const;
105 
110  size_t get_participants(void) const;
111 
116  inline type get_round(void) const
117  {
118  return to_integer();
119  }
120 
125  void set(type value);
126 
134  void set_name(const std::string& var_name, KnowledgeBase& knowledge, int id,
135  int participants);
136 
144  void set_name(const std::string& var_name, Variables& knowledge, int id,
145  int participants);
146 
154  void set_name(const std::string& var_name, ThreadSafeContext& knowledge,
155  int id, int participants);
156 
162  type operator=(type value);
163 
167  void next(void);
168 
173  bool is_done(void);
174 
179  void modify(void);
180 
186  knowledge::KnowledgeRecord to_record(void) const;
187 
192  double to_double(void) const;
193 
198  knowledge::KnowledgeRecord::Integer to_integer(void) const;
199 
204  std::string to_string(void) const;
205 
211  bool operator==(const LegacyBarrier& value) const;
212 
218  bool operator!=(const LegacyBarrier& value) const;
219 
226  void set_quality(uint32_t quality,
228  false));
229 
235  void resize(size_t id = 0, size_t participants = 1);
236 
246  std::string get_debug_info(void);
247 
253  virtual BaseContainer* clone(void) const;
254 
259  bool is_true(void) const;
260 
265  bool is_false(void) const;
266 
267 private:
272  virtual bool is_true_(void) const;
273 
278  virtual bool is_false_(void) const;
279 
288  virtual void modify_(void);
289 
299  virtual std::string get_debug_info_(void);
300 
304  void build_aggregate_barrier(void);
305 
310  inline type barrier_result(void) const
311  {
312 #ifndef _MADARA_NO_KARL_
313  return context_->evaluate(aggregate_barrier_, no_harm).to_integer();
314 #else
315  // note this means that barriers are always successful if no_karl=1
316  return type(1);
317 #endif
318  }
319 
323  void build_var(void);
324 
328  void init_noharm(void);
329 
334 
339 
343  size_t id_;
344 
349 
350 #ifndef _MADARA_NO_KARL_
355 #endif
356 
361 
366 };
367 }
368 }
369 }
370 
371 #endif // _MADARA_CONTAINERS_LEGACY_BARRIER_H_
const ThreadSafeContext * context_
Compiled, optimized KaRL logic.
This class provides a distributed knowledge base to users.
Definition: KnowledgeBase.h:45
This class encapsulates an entry in a KnowledgeBase.
Settings for applying knowledge updates.
Settings for applying knowledge updates.
This class stores variables and their values for use by any entity needing state information in a thr...
Optimized reference to a variable within the knowledge base.
Provides an interface for external functions into the MADARA KaRL variable settings.
Definition: Variables.h:53
This class is an abstract base class for all containers.
Definition: BaseContainer.h:34
This class stores an integer within a variable context.
Definition: LegacyBarrier.h:32
ThreadSafeContext * context_
Variable context that we are modifying.
type barrier_result(void) const
Checks if current barrier is successful.
VariableReference variable_
Variable reference.
size_t id_
id of this barrier in the barrier ring
size_t participants_
the number of participants in the barrier ring
std::string variable_name_
Holder for variable name to quickly refresh modified status.
knowledge::KnowledgeRecord::Integer type
trait that describes the value type
Definition: LegacyBarrier.h:35
type get_round(void) const
Returns the current barrier round.
bool operator==(const LegacyBarrier &value) const
Checks for equality.
CompiledExpression aggregate_barrier_
Expression for aggregating barrier in one atomic operation.
bool operator!=(const LegacyBarrier &value) const
Checks for inequality.
EvalSettings no_harm
Settings we'll use for all evaluations.
Provides container classes for fast knowledge base access and mutation.
Definition: Barrier.h:27
constexpr string_t string
Provides functions and classes for the distributed knowledge base.
Copyright(c) 2020 Galois.
Encapsulates settings for an evaluation statement.
Definition: EvalSettings.h:26