ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
com_patterns.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2017-2020 German Aerospace Center (DLR).
3  * Eclipse ADORe, Automated Driving Open Research https://eclipse.org/adore
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License 2.0 which is available at
7  * http://www.eclipse.org/legal/epl-2.0.
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  * Daniel Heß - initial API and implementation
13  * Matthias Nichting - added class AFeedWithCallback
14  ********************************************************************************/
15 
16 #pragma once
17 #include <functional>
18 #include <string>
19 
20 namespace adore
21 {
22  namespace mad
23  {
27  template<typename T>
28  class AFeed
29  {
30  public:
34  virtual bool hasNext() const =0;
38  virtual void getNext(T& value)=0;
42  virtual void getLatest(T& value)=0;
43  };
44  template<typename T>
46  {
47  public:
51  virtual bool hasNext() const =0;
52  virtual void setCallback(std::function<void()> fcn) = 0;
56  virtual void getNext(T& value)=0;
60  virtual void getLatest(T& value)=0;
61  };
62 
66  template<typename T>
67  class AReader
68  {
69  public:
73  virtual bool hasData() const=0;
77  virtual bool hasUpdate() const=0;
81  virtual void getData(T& value) =0;
86  virtual std::string getDesc()
87  {
88  return std::string(typeid(T).name());
89  }
90  };
91 
95  template<typename T>
96  class AWriter
97  {
98  public:
102  virtual bool canWriteMore() const =0;
106  virtual void write(const T& value)=0;
111  virtual std::string getDesc()
112  {
113  return std::string(typeid(T).name());
114  }
118  virtual uint32_t getNumberOfSubscribers() const
119  {
120  return 0;
121  }
122  };
123 
129  template<typename T>
131  {
132  protected:
134 
135  public:
140  virtual void update() = 0;
141 
150  virtual void discard_radius_based(double x, double y, double z, double radius) = 0;
151 
152  public:
153 
159  virtual void addFeed(AFeed<T> * feed) = 0;
160  };
161  }
162 }
Definition: com_patterns.h:46
virtual void getNext(T &value)=0
virtual bool hasNext() const =0
virtual void setCallback(std::function< void()> fcn)=0
virtual void getLatest(T &value)=0
Definition: com_patterns.h:29
virtual void getNext(T &value)=0
virtual bool hasNext() const =0
virtual void getLatest(T &value)=0
Observer pattern to manage feed data in a storage class.
Definition: com_patterns.h:131
virtual void discard_radius_based(double x, double y, double z, double radius)=0
discard data outside of radius
AFeed< T > * feed_
Definition: com_patterns.h:133
virtual void update()=0
retrieve new objects
virtual void addFeed(AFeed< T > *feed)=0
add source feed to observer
Definition: com_patterns.h:68
virtual void getData(T &value)=0
virtual bool hasData() const =0
virtual bool hasUpdate() const =0
virtual std::string getDesc()
Definition: com_patterns.h:86
Definition: com_patterns.h:97
virtual void write(const T &value)=0
virtual uint32_t getNumberOfSubscribers() const
Definition: com_patterns.h:118
virtual std::string getDesc()
Definition: com_patterns.h:111
virtual bool canWriteMore() const =0
x
Definition: adore_set_goal.py:30
y
Definition: adore_set_goal.py:31
z
Definition: adore_set_goal.py:32
Definition: areaofeffectconverter.h:20