pvAccessCPP  7.1.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
server.h
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 
105 class epicsShareClass StaticProvider {
106 public:
107  POINTER_DEFINITIONS(StaticProvider);
108  struct Impl;
109 private:
110  std::tr1::shared_ptr<Impl> impl; // const after ctor
111 public:
112 
114  struct epicsShareClass ChannelBuilder {
115  POINTER_DEFINITIONS(ChannelBuilder);
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:
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 
163 class epicsShareClass DynamicProvider {
164 public:
165  POINTER_DEFINITIONS(DynamicProvider);
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 
199  struct epicsShareClass Handler {
200  POINTER_DEFINITIONS(Handler);
201  typedef epics::pvData::shared_vector<std::string> names_type;
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
const std::string & name() const
The name being queried.
Definition: server.h:181
An instance of a Client or Server.
Definition: pvAccess.h:1230
virtual void destroy()
Called when the last reference to a DynamicProvider is released. Should close any channels...
Definition: server.h:212
Interface for something which can provide Channels. aka A &quot;PV&quot;. Typically a SharedPV.
Definition: server.h:114
Callbacks associated with DynamicProvider.
Definition: server.h:199
void claim()
Has been claimed()
Definition: server.h:185
_Tp * begin(valarray< _Tp > &__va)
A Provider based on a list of SharedPV instance.
Definition: server.h:105
A single client serach request. May be associated with more than one name.
Definition: server.h:171
_Tp * end(valarray< _Tp > &__va)
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
A Provider which has no pre-configured list of names.
Definition: server.h:163
bool claimed() const
Stake a claim.
Definition: server.h:183
const ::epics::pvAccess::PeerInfo * peer() const
Information about peer making search request.
Definition: server.h:189