This is Unofficial EPICS BASE Doxygen Site
pdbgroup.h
Go to the documentation of this file.
1 #ifndef PDBGROUP_H
2 #define PDBGROUP_H
3 
4 #include <istream>
5 #include <map>
6 #include <limits>
7 
8 #include <dbAccess.h>
9 
10 #include <dbEvent.h>
11 #include <dbLock.h>
12 
13 #include <pv/pvAccess.h>
14 
15 #include "helper.h"
16 #include "pvahelper.h"
17 #include "pvif.h"
18 #include "pdb.h"
19 
20 #include <shareLib.h>
21 
23 {
24  struct QSRV_API Field {
25  std::string type, channel, trigger, id;
26  int putorder;
27 
28  Field() :putorder(std::numeric_limits<int>::min()) {}
29 
30  void swap(Field& o) {
31  std::swap(type, o.type);
32  std::swap(channel, o.channel);
33  std::swap(trigger, o.trigger);
34  std::swap(putorder, o.putorder);
35  std::swap(id, o.id);
36  }
37  };
38 
39  struct QSRV_API Group {
40  typedef std::map<std::string, Field> fields_t;
41  fields_t fields;
42  bool atomic, atomic_set;
43  std::string id;
44 
45  Group() :atomic(true), atomic_set(false) {}
46 
47  void swap(Group& o) {
48  std::swap(fields, o.fields);
49  std::swap(atomic, o.atomic);
50  std::swap(atomic_set, o.atomic_set);
51  std::swap(id, o.id);
52  }
53  };
54 
55  typedef std::map<std::string, Group> groups_t;
56  groups_t groups;
57  std::string warning;
58 
59  void swap(GroupConfig& o) {
60  std::swap(groups, o.groups);
61  std::swap(warning, o.warning);
62  }
63 
64  static void parse(const char *txt,
66 };
67 
68 struct PDBGroupMonitor;
69 
70 void pdb_group_event(void *user_arg, struct dbChannel *chan,
71  int eventsRemaining, struct db_field_log *pfl);
72 
73 struct QSRV_API PDBGroupPV : public PDBPV
74 {
76  weak_pointer weakself;
77  inline shared_pointer shared_from_this() { return shared_pointer(weakself); }
78 
79  // only for use in pdb_single_event()
80  // which is not concurrent for all VALUE/PROPERTY.
82 
84 
85  bool pgatomic, monatomic;
86 
87  // get/put/monitor
88  std::string name;
89 
90  struct Info {
92  std::tr1::shared_ptr<PVIFBuilder> builder;
94  typedef std::vector<size_t> triggers_t;
95  triggers_t triggers; // index in PDBGroupPV::members
96  DBManyLock locker; // lock only those channels being triggered
97  p2p::auto_ptr<PVIF> pvif;
98  DBEvent evt_VALUE, evt_PROPERTY;
99  bool had_initial_VALUE, had_initial_PROPERTY, allowProc;
100 
101  Info() :had_initial_VALUE(false), had_initial_PROPERTY(false), allowProc(false) {}
102  };
104  members_t members;
105 
106  DBManyLock locker; // all member channels
107 
108  epics::pvData::PVStructurePtr complete; // complete copy from subscription
109 
110  typedef std::set<PDBGroupMonitor*> interested_t;
112  interested_t interested, interested_add;
113 
114  typedef std::set<BaseMonitor::shared_pointer> interested_remove_t;
115  interested_remove_t interested_remove;
116 
118 
119  static size_t num_instances;
120 
121  PDBGroupPV();
122  virtual ~PDBGroupPV();
123 
124  virtual
125  epics::pvAccess::Channel::shared_pointer
126  connect(const std::tr1::shared_ptr<PDBProvider>& prov,
127  const epics::pvAccess::ChannelRequester::shared_pointer& req) OVERRIDE FINAL;
128 
129  void addMonitor(PDBGroupMonitor*);
130  void removeMonitor(PDBGroupMonitor*);
131  void finalizeMonitor();
132 
133  virtual void show(int lvl) OVERRIDE;
134 };
135 
137  public std::tr1::enable_shared_from_this<PDBGroupChannel>
138 {
140 
141  PDBGroupPV::shared_pointer pv;
142  std::vector<ASCLIENT> aspvt;
143  // storage referenced from aspvt
145 
146  static size_t num_instances;
147 
148  PDBGroupChannel(const PDBGroupPV::shared_pointer& pv,
149  const std::tr1::shared_ptr<epics::pvAccess::ChannelProvider>& prov,
150  const epics::pvAccess::ChannelRequester::shared_pointer& req);
151  virtual ~PDBGroupChannel();
152 
153  virtual epics::pvAccess::ChannelPut::shared_pointer createChannelPut(
154  epics::pvAccess::ChannelPutRequester::shared_pointer const & requester,
155  epics::pvData::PVStructure::shared_pointer const & pvRequest) OVERRIDE FINAL;
156  virtual epics::pvData::Monitor::shared_pointer createMonitor(
157  epics::pvData::MonitorRequester::shared_pointer const & requester,
158  epics::pvData::PVStructure::shared_pointer const & pvRequest) OVERRIDE FINAL;
159 
160  virtual void printInfo(std::ostream& out) OVERRIDE FINAL;
161 };
162 
164  public std::tr1::enable_shared_from_this<PDBGroupPut>
165 {
168  PDBGroupChannel::shared_pointer channel;
169  requester_type::weak_pointer requester;
170 
171  // effectively const after ctor
172  bool atomic, doWait;
174 
177  std::vector<std::tr1::shared_ptr<PVIF> > pvif;
178 
179  static size_t num_instances;
180 
181  PDBGroupPut(const PDBGroupChannel::shared_pointer &channel,
182  const epics::pvAccess::ChannelPutRequester::shared_pointer &requester,
183  const epics::pvData::PVStructure::shared_pointer& pvReq);
184  virtual ~PDBGroupPut();
185 
186  virtual void destroy() OVERRIDE FINAL { pvif.clear(); channel.reset(); requester.reset(); }
187  virtual std::tr1::shared_ptr<epics::pvAccess::Channel> getChannel() OVERRIDE FINAL { return channel; }
188  virtual void cancel() OVERRIDE FINAL {}
189  virtual void lastRequest() OVERRIDE FINAL {}
190  virtual void put(
191  epics::pvData::PVStructure::shared_pointer const & pvPutStructure,
192  epics::pvData::BitSet::shared_pointer const & putBitSet) OVERRIDE FINAL;
193  virtual void get() OVERRIDE FINAL;
194 };
195 
197 {
199 
200  PDBGroupPV::shared_pointer pv;
201 
202  bool atomic;
203 
204  static size_t num_instances;
205 
206  PDBGroupMonitor(const PDBGroupPV::shared_pointer& pv,
207  const requester_type::weak_pointer& requester,
208  const epics::pvData::PVStructure::shared_pointer& pvReq);
209  virtual ~PDBGroupMonitor();
210 
211  virtual void onStart() OVERRIDE FINAL;
212  virtual void onStop() OVERRIDE FINAL;
213  virtual void requestUpdate() OVERRIDE FINAL;
214 
215  virtual void destroy() OVERRIDE FINAL;
216 
217 };
218 
219 #endif // PDBGROUP_H
std::vector< ASCLIENT > aspvt
Definition: pdbgroup.h:142
std::vector< std::tr1::shared_ptr< PVIF > > pvif
Definition: pdbgroup.h:177
DBManyLock locker
Definition: pdbgroup.h:96
members_t members
Definition: pdbgroup.h:104
epics::pvData::PVStructurePtr pvf
Definition: pdbgroup.h:176
pvac::PutEvent result
Definition: clientSync.cpp:117
PDBGroupPV::shared_pointer pv
Definition: pdbgroup.h:200
bool doWait
Definition: pdbgroup.h:172
static size_t num_instances
Definition: pdbgroup.h:146
std::tr1::shared_ptr< detail::SharedPut > put
std::vector< size_t > triggers_t
Definition: pdbgroup.h:94
#define true
Definition: flexdef.h:84
std::string id
Definition: pdbgroup.h:25
std::set< PDBGroupMonitor * > interested_t
Definition: pdbgroup.h:110
#define min(x, y)
Definition: flexdef.h:78
epics::pvData::shared_vector< Info > members_t
Definition: pdbgroup.h:103
virtual void lastRequest() OVERRIDE FINAL
Definition: pdbgroup.h:189
proc_t
Definition: pvif.h:361
PDBGroupPV::shared_pointer pv
Definition: pdbgroup.h:141
std::set< BaseMonitor::shared_pointer > interested_remove_t
Definition: pdbgroup.h:114
Definition: memory.hpp:41
DBManyLock locker
Definition: pdbgroup.h:106
void swap(GroupConfig &o)
Definition: pdbgroup.h:59
std::string channel
Definition: pdbgroup.h:25
A vector of bits.
Definition: bitSet.h:56
epics::pvData::BitSet scratch
Definition: pdbgroup.h:81
Mark external symbols and entry points for shared libraries.
interested_t interested_add
Definition: pdbgroup.h:112
static size_t num_instances
Definition: pdbgroup.h:179
#define OVERRIDE
Definition: pvAccess.h:55
std::string type
Definition: pdbgroup.h:25
size_t initial_waits
Definition: pdbgroup.h:117
virtual void destroy() OVERRIDE FINAL
Definition: pdbgroup.h:186
std::string warning
Definition: pdbgroup.h:57
epics::pvData::PVStructurePtr complete
Definition: pdbgroup.h:108
POINTER_DEFINITIONS(PDBPV)
virtual void cancel() OVERRIDE FINAL
Definition: pdbgroup.h:188
Definition: pvif.h:91
#define POINTER_DEFINITIONS(clazz)
Definition: sharedPtr.h:198
void swap(Group &o)
Definition: pdbgroup.h:47
PDBGroupChannel::shared_pointer channel
Definition: pdbgroup.h:168
interested_remove_t interested_remove
Definition: pdbgroup.h:115
void pdb_group_event(void *user_arg, struct dbChannel *chan, int eventsRemaining, struct db_field_log *pfl)
Definition: pdbgroup.cpp:30
virtual std::tr1::shared_ptr< epics::pvAccess::Channel > getChannel() OVERRIDE FINAL
Definition: pdbgroup.h:187
const ChannelProcessRequester::weak_pointer requester
Definition: pvAccess.cpp:68
groups_t groups
Definition: pdbgroup.h:56
#define QSRV_API
Definition: qsrv.h:36
std::string name
Definition: pdbgroup.h:88
weak_pointer weakself
Definition: pdbgroup.h:76
bool interested_iterating
Definition: pdbgroup.h:111
void swap(Field &o)
Definition: pdbgroup.h:30
epics::pvData::BitSetPtr changed
Definition: pdbgroup.h:175
Definition: pvif.h:72
requester_type::weak_pointer requester
Definition: pdbgroup.h:169
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
std::string trigger
Definition: pdbgroup.h:25
epics::pvAccess::ChannelPutRequester requester_t
Definition: pdbgroup.h:167
shared_pointer shared_from_this()
Definition: pdbgroup.h:77
static size_t num_instances
Definition: pdbgroup.h:119
Definition: pvif.h:214
FieldName attachment
Definition: pdbgroup.h:93
DBEvent evt_VALUE
Definition: pdbgroup.h:98
std::map< std::string, Field > fields_t
Definition: pdbgroup.h:40
void swap(shared_ptr< T > &a, shared_ptr< T > &b) BOOST_NOEXCEPT
Definition: shared_ptr.hpp:783
std::map< std::string, Group > groups_t
Definition: pdbgroup.h:55
triggers_t triggers
Definition: pdbgroup.h:95
std::string id
Definition: pdbgroup.h:43
bool pgatomic
Definition: pdbgroup.h:85
std::tr1::shared_ptr< BitSet > BitSetPtr
Definition: bitSet.h:26
p2p::auto_ptr< PVIF > pvif
Definition: pdbgroup.h:97
fields_t fields
Definition: pdbgroup.h:41
bool had_initial_VALUE
Definition: pdbgroup.h:99
std::tr1::shared_ptr< PVIFBuilder > builder
Definition: pdbgroup.h:92
static size_t num_instances
Definition: pdbgroup.h:204
#define false
Definition: flexdef.h:85
#define FINAL
Definition: pvAccess.h:48
Definition: pdb.h:15
PVIF::proc_t doProc
Definition: pdbgroup.h:173
epicsMutex lock
Definition: pdbgroup.h:83