ODIN
blackboard.h
1 /***************************************************************************
2  blackboard.h - description
3  -------------------
4  begin : Mon Jan 24 2007
5  copyright : (C) 2000-2021 by Thies Jochimsen
6  email : thies@jochimsen.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef RECOBLACKBOARD_H
19 #define RECOBLACKBOARD_H
20 
21 #include <odinreco/odinreco.h>
22 #include <odinreco/data.h>
23 #include <odinreco/step.h>
24 
36 
37  public:
38 
43 
44  ~RecoBlackBoard();
45 
49  void announce(const STD_string& label) {ann[label]++;}
50 
54  void post(const STD_string& label, const RecoData& data);
55 
59  bool announced(const STD_string& label) const {return ann.find(label)!=ann.end();}
60 
66  bool inquire(const STD_string& label, RecoData& data, bool blocking);
67 
72 
73 
74  private:
75 
76  bool get_data(const STD_string& label, RecoData& data);
77 
78  // The data on the blackboard
79  typedef STD_map<RecoCoord, RecoData> CoordDataMap;
80  typedef STD_map<STD_string,CoordDataMap> LabelDataMap;
81  LabelDataMap posted;
82  Mutex postedmutex;
83 
84  // The events to signal the availability of new data
85  typedef STD_map<RecoCoord, Event*> CoordEventMap;
86  typedef STD_map<STD_string,CoordEventMap> LabelEventMap;
87  LabelEventMap eventmap;
88  Mutex eventmutex;
89 
90 
91  STD_map<STD_string,UInt> ann;
92 
93 };
94 
95 
100 
101 
102 class RecoPost : public RecoStep {
103 
104  // implementing virtual functions of RecoStep
105  STD_string label() const {return "post";}
106  STD_string description() const {return "Post data on blackboard";}
107  bool process(RecoData& rd, RecoController& controller);
108  RecoCoord input_coord() const {return RecoCoord::any();}
109  void modify_coord(RecoCoord& coord) const {}
110  bool query(RecoQueryContext& context);
111  RecoStep* allocate() const {return new RecoPost;}
112  void init();
113 
114  LDRstring postlabel;
115 
116 };
117 
118 
119 
120 #endif
121 
Definition: tjthread.h:46
bool announced(const STD_string &label) const
Definition: blackboard.h:59
void post(const STD_string &label, const RecoData &data)
bool inquire(const STD_string &label, RecoData &data, bool blocking)
void announce(const STD_string &label)
Definition: blackboard.h:49
void release_waiting_threads()
post: Post data on blackboard
Definition: blackboard.h:102
static RecoCoord any()
Definition: index.h:219