ODIN
odinreco
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
35
class
RecoBlackBoard
{
36
37
public
:
38
42
RecoBlackBoard
() {}
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
71
void
release_waiting_threads
();
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
LDRstring
Definition:
ldrtypes.h:36
Mutex
Definition:
tjthread.h:46
RecoBlackBoard
Definition:
blackboard.h:35
RecoBlackBoard::announced
bool announced(const STD_string &label) const
Definition:
blackboard.h:59
RecoBlackBoard::post
void post(const STD_string &label, const RecoData &data)
RecoBlackBoard::inquire
bool inquire(const STD_string &label, RecoData &data, bool blocking)
RecoBlackBoard::announce
void announce(const STD_string &label)
Definition:
blackboard.h:49
RecoBlackBoard::RecoBlackBoard
RecoBlackBoard()
Definition:
blackboard.h:42
RecoBlackBoard::release_waiting_threads
void release_waiting_threads()
RecoController
Definition:
controller.h:51
RecoData
Definition:
odinreco/data.h:48
RecoPost
post: Post data on blackboard
Definition:
blackboard.h:102
RecoStep
Definition:
odinreco/step.h:84
RecoCoord
Definition:
index.h:158
RecoCoord::any
static RecoCoord any()
Definition:
index.h:219
RecoQueryContext
Definition:
odinreco/step.h:40
Generated on Fri Oct 15 2021 11:36:52 for ODIN by
1.9.1