This is Unofficial EPICS BASE Doxygen Site
server.h
Go to the documentation of this file.
1 /*
2  * Copyright information and license terms for this software can be
3  * found in the file LICENSE that is included with the distribution
4  */
5 #ifndef PVA_SERVER_H
6 #define PVA_SERVER_H
7 
8 #include <string>
9 #include <vector>
10 #include <map>
11 
12 #include <shareLib.h>
13 #include <pv/sharedPtr.h>
14 #include <pv/sharedVector.h>
15 
16 namespace epics{namespace pvAccess{
17 class ChannelProvider;
18 class Channel;
19 class ChannelRequester;
20 struct PeerInfo; // see pv/security.h
21 }} // epics::pvAccess
22 
24 namespace pvas {
25 
106 public:
108  struct Impl;
109 private:
110  std::tr1::shared_ptr<Impl> impl; // const after ctor
111 public:
112 
116  virtual ~ChannelBuilder();
118  virtual std::tr1::shared_ptr<epics::pvAccess::Channel> connect(const std::tr1::shared_ptr<epics::pvAccess::ChannelProvider>& provider,
119  const std::string& name,
120  const std::tr1::shared_ptr<epics::pvAccess::ChannelRequester>& requester) =0;
123  virtual void disconnect(bool destroy, const epics::pvAccess::ChannelProvider* provider) =0;
124  };
125 private:
126  typedef std::map<std::string, std::tr1::shared_ptr<ChannelBuilder> > builders_t;
127 public:
128  typedef builders_t::const_iterator const_iterator;
129 
132  explicit StaticProvider(const std::string& name);
133  ~StaticProvider();
134 
138  void close(bool destroy=false);
139 
141  void add(const std::string& name,
142  const std::tr1::shared_ptr<ChannelBuilder>& builder);
146  std::tr1::shared_ptr<ChannelBuilder> remove(const std::string& name);
147 
149  std::tr1::shared_ptr<epics::pvAccess::ChannelProvider> provider() const;
150 
151  // iterate through currently add()'d PVs. Iteraters are invalidated by concurrent add() or remove()
152  const_iterator begin() const;
153  const_iterator end() const;
154 };
155 
164 public:
166  struct Impl;
167 private:
168  std::tr1::shared_ptr<Impl> impl; // const after ctor
169 public:
171  class Search {
172  friend struct Impl;
173  bool isclaimed;
174  std::string cname;
175  const ::epics::pvAccess::PeerInfo* peerinfo;
176  Search(const std::string& name, const ::epics::pvAccess::PeerInfo* peer)
177  :isclaimed(false),cname(name),peerinfo(peer)
178  {}
179  public:
181  const std::string& name() const { return cname; }
183  bool claimed() const { return isclaimed; }
185  void claim() { isclaimed = true; }
189  const ::epics::pvAccess::PeerInfo* peer() const { return peerinfo; }
190  };
191  typedef std::vector<Search> search_type;
192 
202  virtual ~Handler() {}
204  virtual void hasChannels(search_type& name) =0;
206  virtual void listChannels(names_type& names, bool& dynamic) {}
208  virtual std::tr1::shared_ptr<epics::pvAccess::Channel> createChannel(const std::tr1::shared_ptr<epics::pvAccess::ChannelProvider>& provider,
209  const std::string& name,
210  const std::tr1::shared_ptr<epics::pvAccess::ChannelRequester>& requester) =0;
212  virtual void destroy() {}
213  };
214 
218  DynamicProvider(const std::string& name,
219  const std::tr1::shared_ptr<Handler>& handler);
220  ~DynamicProvider();
221 
222  Handler::shared_pointer getHandler() const;
223 
224  //void close();
225 
227  std::tr1::shared_ptr<epics::pvAccess::ChannelProvider> provider() const;
228 };
229 
231 
232 } // namespace pvas
233 
234 #endif // PVA_SERVER_H
A single client serach request. May be associated with more than one name.
Definition: server.h:171
Interface for something which can provide Channels. aka A "PV". Typically a SharedPV.
Definition: server.h:114
std::vector< Search > search_type
Definition: server.h:191
TODO only here because of the Lockable.
Definition: ntaggregate.cpp:16
Mark external symbols and entry points for shared libraries.
epicsTime begin
Definition: caConnTest.cpp:22
virtual void destroy()
Called when the last reference to a DynamicProvider is released. Should close any channels...
Definition: server.h:212
builders_t::const_iterator const_iterator
Definition: server.h:128
const ::epics::pvAccess::PeerInfo * peer() const
Definition: server.h:189
A Provider which has no pre-configured list of names.
Definition: server.h:163
const std::string & name() const
The name being queried.
Definition: server.h:181
#define POINTER_DEFINITIONS(clazz)
Definition: sharedPtr.h:198
const ChannelProcessRequester::weak_pointer requester
Definition: pvAccess.cpp:68
#define epicsShareClass
Definition: shareLib.h:206
See Server API API.
epics::pvData::shared_vector< std::string > names_type
Definition: server.h:201
A Provider based on a list of SharedPV instance.
Definition: server.h:105
void claim()
Has been claimed()
Definition: server.h:185
virtual void listChannels(names_type &names, bool &dynamic)
Called when a client is requesting a list of channel names we provide. Callee should set dynamic=fals...
Definition: server.h:206
bool claimed() const
Stake a claim.
Definition: server.h:183
#define false
Definition: flexdef.h:85