13 #ifdef epicsExportSharedSymbols
14 # define pvAccessEpicsExportSharedSymbols
15 # undef epicsExportSharedSymbols
18 #include <pv/pvData.h>
19 #include <pv/createRequest.h>
20 #include <pv/status.h>
21 #include <pv/bitSet.h>
23 #ifdef pvAccessEpicsExportSharedSymbols
24 # define epicsExportSharedSymbols
25 # undef pvAccessEpicsExportSharedSymbols
28 #include <pv/pvaVersion.h>
29 #include <pv/destroyable.h>
30 #include <pv/monitor.h>
45 # if __cplusplus>=201103L
52 # if __cplusplus>=201103L
53 # define OVERRIDE override
64 using epics::pvData::Requester;
65 using epics::pvData::RequesterPtr;
66 using epics::pvData::MessageType;
67 using epics::pvData::getMessageTypeName;
90 class epicsShareClass Lockable
93 POINTER_DEFINITIONS(Lockable);
95 virtual ~Lockable() {}
97 virtual void lock() {}
98 virtual void unlock() {}
108 explicit ScopedLock(Lockable::shared_pointer
const & li)
109 : lockable(li), locked(
true) {
131 bool ownsLock()
const {
137 Lockable::shared_pointer
const lockable;
144 class ChannelFindRequester;
160 inline Counter() :tx(0u), rx(0u) {}
164 Counter transportBytes;
165 Counter operationBytes;
168 inline Stats() :populated(
false) {}
173 virtual void stats(Stats& s)
const =0;
181 static size_t num_instances;
212 static size_t num_instances;
221 virtual std::tr1::shared_ptr<Channel> getChannel() = 0;
231 virtual void cancel() = 0;
237 virtual void lastRequest() = 0;
263 virtual void monitorConnect(epics::pvData::Status
const & status,
264 MonitorPtr
const & monitor, epics::pvData::StructureConstPtr
const & structure) = 0;
271 virtual void monitorEvent(MonitorPtr
const & monitor) = 0;
276 virtual void unlisten(MonitorPtr
const & monitor) = 0;
301 virtual void putArray(
302 epics::pvData::PVArray::shared_pointer
const & putArray,
303 size_t offset = 0,
size_t count = 0,
size_t stride = 1) = 0;
315 virtual void getArray(
size_t offset = 0,
size_t count = 0,
size_t stride = 1) = 0;
320 virtual void getLength() = 0;
326 virtual void setLength(
size_t length) = 0;
347 virtual void channelArrayConnect(
348 const epics::pvData::Status& status,
349 ChannelArray::shared_pointer
const & channelArray,
350 epics::pvData::Array::const_shared_pointer
const & array) = 0;
360 virtual void putArrayDone(
361 const epics::pvData::Status& status,
362 ChannelArray::shared_pointer
const & channelArray) = 0;
374 virtual void getArrayDone(
375 const epics::pvData::Status& status,
376 ChannelArray::shared_pointer
const & channelArray,
377 epics::pvData::PVArray::shared_pointer
const & pvArray) = 0;
385 virtual void getLengthDone(
386 const epics::pvData::Status& status,
387 ChannelArray::shared_pointer
const & channelArray,
395 virtual void setLengthDone(
396 const epics::pvData::Status& status,
397 ChannelArray::shared_pointer
const & channelArray) = 0;
404 class epicsShareClass ChannelFind :
public Destroyable {
405 EPICS_NOT_COPYABLE(ChannelFind)
407 POINTER_DEFINITIONS(ChannelFind);
408 typedef ChannelFindRequester requester_type;
411 virtual ~ChannelFind() {}
413 virtual std::tr1::shared_ptr<ChannelProvider> getChannelProvider() = 0;
414 virtual void cancel() = 0;
418 static ChannelFind::shared_pointer buildDummy(
const std::tr1::shared_ptr<ChannelProvider>& provider);
426 class epicsShareClass ChannelFindRequester {
428 POINTER_DEFINITIONS(ChannelFindRequester);
429 typedef ChannelFind operation_type;
431 virtual ~ChannelFindRequester() {}
436 virtual void channelFindResult(
437 const epics::pvData::Status& status,
438 ChannelFind::shared_pointer
const & channelFind,
462 virtual std::tr1::shared_ptr<const PeerInfo> getPeerInfo()
463 {
return std::tr1::shared_ptr<const PeerInfo>(); }
469 class epicsShareClass ChannelListRequester {
471 POINTER_DEFINITIONS(ChannelListRequester);
472 typedef ChannelFind operation_type;
474 virtual ~ChannelListRequester() {}
479 virtual void channelListResult(
480 const epics::pvData::Status& status,
481 ChannelFind::shared_pointer
const & channelFind,
482 epics::pvData::PVStringArray::const_svector
const & channelNames,
483 bool hasDynamic) = 0;
504 virtual void get() = 0;
524 virtual void channelGetConnect(
525 const epics::pvData::Status& status,
526 ChannelGet::shared_pointer
const & channelGet,
527 epics::pvData::Structure::const_shared_pointer
const & structure) = 0;
540 virtual void getDone(
541 const epics::pvData::Status& status,
542 ChannelGet::shared_pointer
const & channelGet,
543 epics::pvData::PVStructure::shared_pointer
const & pvStructure,
544 epics::pvData::BitSet::shared_pointer
const & bitSet) = 0;
562 virtual void process() = 0;
582 virtual void channelProcessConnect(
583 const epics::pvData::Status& status,
584 ChannelProcess::shared_pointer
const & channelProcess) = 0;
591 virtual void processDone(
592 const epics::pvData::Status& status,
593 ChannelProcess::shared_pointer
const & channelProcess) = 0;
620 epics::pvData::PVStructure::shared_pointer
const & pvPutStructure,
621 epics::pvData::BitSet::shared_pointer
const & putBitSet) = 0;
628 virtual void get() = 0;
648 virtual void channelPutConnect(
649 const epics::pvData::Status& status,
650 ChannelPut::shared_pointer
const & channelPut,
651 epics::pvData::Structure::const_shared_pointer
const & structure) = 0;
658 virtual void putDone(
659 const epics::pvData::Status& status,
660 ChannelPut::shared_pointer
const & channelPut) = 0;
672 virtual void getDone(
673 const epics::pvData::Status& status,
674 ChannelPut::shared_pointer
const & channelPut,
675 epics::pvData::PVStructure::shared_pointer
const & pvStructure,
676 epics::pvData::BitSet::shared_pointer
const & bitSet) = 0;
698 epics::pvData::PVStructure::shared_pointer
const & pvPutStructure,
699 epics::pvData::BitSet::shared_pointer
const & putBitSet) = 0;
705 virtual void getPut() = 0;
711 virtual void getGet() = 0;
733 virtual void channelPutGetConnect(
734 const epics::pvData::Status& status,
735 ChannelPutGet::shared_pointer
const & channelPutGet,
736 epics::pvData::Structure::const_shared_pointer
const & putStructure,
737 epics::pvData::Structure::const_shared_pointer
const & getStructure) = 0;
746 virtual void putGetDone(
747 const epics::pvData::Status& status,
748 ChannelPutGet::shared_pointer
const & channelPutGet,
749 epics::pvData::PVStructure::shared_pointer
const & pvGetStructure,
750 epics::pvData::BitSet::shared_pointer
const & getBitSet) = 0;
759 virtual void getPutDone(
760 const epics::pvData::Status& status,
761 ChannelPutGet::shared_pointer
const & channelPutGet,
762 epics::pvData::PVStructure::shared_pointer
const & pvPutStructure,
763 epics::pvData::BitSet::shared_pointer
const & putBitSet) = 0;
772 virtual void getGetDone(
773 const epics::pvData::Status& status,
774 ChannelPutGet::shared_pointer
const & channelPutGet,
775 epics::pvData::PVStructure::shared_pointer
const & pvGetStructure,
776 epics::pvData::BitSet::shared_pointer
const & getBitSet) = 0;
804 virtual void request(epics::pvData::PVStructure::shared_pointer
const & pvArgument) = 0;
830 virtual void channelRPCConnect(
831 const epics::pvData::Status& status,
832 ChannelRPC::shared_pointer
const & operation) = 0;
843 virtual void requestDone(
844 const epics::pvData::Status& status,
845 ChannelRPC::shared_pointer
const & operation,
846 epics::pvData::PVStructure::shared_pointer
const & pvResponse) = 0;
867 virtual void getDone(
868 const epics::pvData::Status& status,
869 epics::pvData::FieldConstPtr
const & field) = 0;
895 static size_t num_instances;
901 virtual void message(
std::string const & message, epics::pvData::MessageType messageType);
907 NEVER_CONNECTED, CONNECTED, DISCONNECTED, DESTROYED
910 static const char* ConnectionStateNames[];
916 virtual std::tr1::shared_ptr<ChannelProvider> getProvider() = 0;
932 virtual ConnectionState getConnectionState();
944 virtual std::tr1::shared_ptr<ChannelRequester> getChannelRequester() = 0;
949 virtual bool isConnected();
961 virtual void getField(GetFieldRequester::shared_pointer
const & requester,
std::string const & subField);
969 virtual AccessRights getAccessRights(epics::pvData::PVField::shared_pointer
const & pvField);
988 virtual ChannelProcess::shared_pointer createChannelProcess(
989 ChannelProcessRequester::shared_pointer
const & requester,
990 epics::pvData::PVStructure::shared_pointer
const & pvRequest);
1009 virtual ChannelGet::shared_pointer createChannelGet(
1010 ChannelGetRequester::shared_pointer
const & requester,
1011 epics::pvData::PVStructure::shared_pointer
const & pvRequest);
1030 virtual ChannelPut::shared_pointer createChannelPut(
1031 ChannelPutRequester::shared_pointer
const & requester,
1032 epics::pvData::PVStructure::shared_pointer
const & pvRequest);
1051 virtual ChannelPutGet::shared_pointer createChannelPutGet(
1052 ChannelPutGetRequester::shared_pointer
const & requester,
1053 epics::pvData::PVStructure::shared_pointer
const & pvRequest);
1072 virtual ChannelRPC::shared_pointer createChannelRPC(
1073 ChannelRPCRequester::shared_pointer
const & requester,
1074 epics::pvData::PVStructure::shared_pointer
const & pvRequest);
1093 virtual Monitor::shared_pointer createMonitor(
1094 MonitorRequester::shared_pointer
const & requester,
1095 epics::pvData::PVStructure::shared_pointer
const & pvRequest);
1119 virtual ChannelArray::shared_pointer createChannelArray(
1120 ChannelArrayRequester::shared_pointer
const & requester,
1121 epics::pvData::PVStructure::shared_pointer
const & pvRequest);
1144 ChannelRequester&
operator=(
const ChannelRequester&);
1146 POINTER_DEFINITIONS(ChannelRequester);
1149 static size_t num_instances;
1152 virtual ~ChannelRequester();
1174 virtual void channelCreated(
const epics::pvData::Status& status, Channel::shared_pointer
const & channel) = 0;
1185 virtual void channelStateChange(Channel::shared_pointer
const & channel,
Channel::ConnectionState connectionState) = 0;
1205 virtual std::tr1::shared_ptr<const PeerInfo> getPeerInfo();
1212 virtual std::string getRequesterName() OVERRIDE FINAL;
1213 virtual void channelCreated(
const epics::pvData::Status& status, Channel::shared_pointer
const & channel) OVERRIDE FINAL;
1214 virtual void channelStateChange(Channel::shared_pointer
const & channel,
Channel::ConnectionState connectionState) OVERRIDE FINAL;
1215 static ChannelRequester::shared_pointer build();
1222 IMMEDIATE, DELAYED, USER_CONTROLED
1237 static const short PRIORITY_MIN = 0;
1239 static const short PRIORITY_MAX = 99;
1241 static const short PRIORITY_DEFAULT = PRIORITY_MIN;
1243 static const short PRIORITY_LINKS_DB = PRIORITY_MAX;
1245 static const short PRIORITY_ARCHIVE = (PRIORITY_MAX + PRIORITY_MIN) / 2;
1247 static const short PRIORITY_OPI = PRIORITY_MIN;
1249 static size_t num_instances;
1270 virtual ChannelFind::shared_pointer channelFind(
std::string const & name,
1271 ChannelFindRequester::shared_pointer
const & requester) = 0;
1282 virtual ChannelFind::shared_pointer channelList(ChannelListRequester::shared_pointer
const & requester);
1287 virtual Channel::shared_pointer createChannel(
std::string const & name,
1288 ChannelRequester::shared_pointer
const & requester = DefaultChannelRequester::build(),
1289 short priority = PRIORITY_DEFAULT);
1314 virtual Channel::shared_pointer createChannel(
std::string const & name,ChannelRequester::shared_pointer
const & requester,
1339 virtual ChannelProvider::shared_pointer sharedInstance() = 0;
1346 return newInstance(std::tr1::shared_ptr<Configuration>());
1353 virtual ChannelProvider::shared_pointer
newInstance(
const std::tr1::shared_ptr<Configuration>&) {
1354 throw std::logic_error(
"This ChannelProviderFactory does not support non-default configurations");
1361 template<
class Prov
ider>
1371 epics::pvData::Lock L(sharedM);
1372 ChannelProvider::shared_pointer ret(shared.lock());
1374 std::tr1::shared_ptr<Provider> inst(
new Provider(std::tr1::shared_ptr<Configuration>()));
1375 shared = ret = inst;
1380 virtual ChannelProvider::shared_pointer
newInstance(
const std::tr1::shared_ptr<Configuration>& conf) OVERRIDE FINAL
1382 std::tr1::shared_ptr<Provider> ret(
new Provider(conf));
1388 epics::pvData::Mutex sharedM;
1389 ChannelProvider::weak_pointer shared;
1396 template<
class Prov
ider>
1400 const std::tr1::shared_ptr<const Configuration>& conf = std::tr1::shared_ptr<const Configuration>())
1401 :pname(name), config(conf)
1409 epics::pvData::Lock L(sharedM);
1410 ChannelProvider::shared_pointer ret(shared.lock());
1412 std::tr1::shared_ptr<Provider> inst(
new Provider(config));
1413 shared = ret = inst;
1418 virtual ChannelProvider::shared_pointer
newInstance(
const std::tr1::shared_ptr<Configuration>& conf) OVERRIDE FINAL
1425 epics::pvData::Mutex sharedM;
1426 ChannelProvider::weak_pointer shared;
1427 const std::tr1::shared_ptr<const Configuration> config;
1443 static ChannelProviderRegistry::shared_pointer build();
1448 static ChannelProviderRegistry::shared_pointer clients();
1453 static ChannelProviderRegistry::shared_pointer servers();
1460 ChannelProvider::shared_pointer getProvider(
std::string const & providerName);
1467 ChannelProvider::shared_pointer createProvider(
std::string const & providerName,
1468 const std::tr1::shared_ptr<Configuration>& conf = std::tr1::shared_ptr<Configuration>());
1475 virtual ChannelProviderFactory::shared_pointer getFactory(
std::string const & providerName);
1485 virtual bool add(
const ChannelProviderFactory::shared_pointer& fact,
bool replace=
true);
1488 template<
class Prov
ider>
1492 typename Factory::shared_pointer fact(
new Factory(name));
1493 return add(fact,
replace) ? fact :
typename Factory::shared_pointer();
1496 typedef ChannelProvider::shared_pointer (*factoryfn_t)(
const std::tr1::shared_ptr<Configuration>&);
1498 ChannelProviderFactory::shared_pointer add(
const std::string& name, factoryfn_t,
bool replace=
true);
1501 template<
class Prov
ider>
1503 const std::tr1::shared_ptr<const Configuration>& conf = std::tr1::shared_ptr<const Configuration>(),
1507 typename Factory::shared_pointer fact(
new Factory(name, conf));
1508 return add(fact,
replace) ? fact :
typename Factory::shared_pointer();
1515 ChannelProviderFactory::shared_pointer addSingleton(
const ChannelProvider::shared_pointer& provider,
1519 ChannelProviderFactory::shared_pointer
remove(
const std::string& name);
1522 virtual bool remove(
const ChannelProviderFactory::shared_pointer& factory);
1525 virtual void clear();
1531 friend struct CompatRegistry;
1533 epics::pvData::Mutex mutex;
1535 providers_t providers;
1543 #if __GNUC__>4 || (__GNUC__==4&&__GNUC_MINOR__>=3)
1545 #define gCPRMSG __attribute__((error("ChannelProvider shared_ptr ownership rules have changed.")))
1547 epicsShareFunc ChannelProviderRegistry::shared_pointer getChannelProviderRegistry() gCPRMSG;
1549 epicsShareFunc
void registerChannelProviderFactory(ChannelProviderFactory::shared_pointer const & channelProviderFactory) gCPRMSG;
1551 epicsShareFunc
void unregisterChannelProviderFactory(ChannelProviderFactory::shared_pointer const & channelProviderFactory) gCPRMSG;
1553 epicsShareFunc
void unregisterAllChannelProviderFactory() gCPRMSG;
1570 namespace epics {
namespace pvData {
Both read and write access are allowed.
Expose statistics related to network transport.
Read access is allowed but write access is not allowed.
ChannelProviderFactory::shared_pointer addSingleton(const std::string &name, const std::tr1::shared_ptr< const Configuration > &conf=std::tr1::shared_ptr< const Configuration >(), bool replace=true)
Add a new Provider which will be built using SingletonChannelProviderFactory<Provider> ...
Requester for ChannelPut.
virtual std::string getFactoryName()
Get factory name (i.e.
FlushStrategy
The FlushStrategy enum.
ConnectionState
Channel connection status.
Base interface for all channel requests (aka.
complex< _Tp > & operator=(const _Tp &)
iterator_traits< _InputIterator >::difference_type count(_InputIterator __first, _InputIterator __last, const _Tp &__value)
Requester for ChannelPutGet.
virtual ChannelProvider::shared_pointer sharedInstance()
Get a shared instance using the default Configuration.
Neither read or write access is allowed.
Callback class for passing messages to a requester.
virtual ChannelProvider::shared_pointer newInstance(const std::tr1::shared_ptr< Configuration > &conf)
Create a new instance using a specific Configuration.
virtual std::string getFactoryName()
Get factory name (i.e.
Base for all Requesters (callbacks to client)
Access to Monitor subscription and queue.
An instance of a Client or Server.
Requester for channelProcess.
ChannelProcess - request that a channel be processed.
ChannelProviderFactory::shared_pointer add(const std::string &name, bool replace=true)
Add a new Provider which will be built using SimpleChannelProviderFactory<Provider> ...
Monitor PipelineMonitor
Pipeline (streaming) support API (optional).
virtual void printInfo(std::ostream &out)
Prints detailed information about the context to the specified output stream.
Used when ChannelProvider::createChannel() is passed a NULL ChannelRequester.
void lock(_L1 &__l1, _L2 &__l2, _L3 &...__l3)
Simple ChannelProviderFactory which requires the existance of a ctor Provider(const std::tr1::shared_...
virtual ChannelProvider::shared_pointer sharedInstance()
Get a shared instance using the default Configuration.
ChanneProvider factory interface.
Callback implemented by monitor clients.
Handle for an RPC operation.
virtual ChannelProvider::shared_pointer newInstance(const std::tr1::shared_ptr< Configuration > &)
Create a new instance using a specific Configuration.
virtual ChannelProvider::shared_pointer newInstance(const std::tr1::shared_ptr< Configuration > &conf)
Create a new instance using a specific Configuration.
Completion notification for Channel::getField()
Request to put and get Array Data.
The interface through which Operations (get, put, monitor, ...) are initiated.
Instance declaring destroy method.
Interface for locating channel providers.
Event notifications associated with Channel life-cycle.
Requester for channelGet.
Channel access put/get request.
Request to get data from a channel.
Interface for a channel access put request.
The Requester for a ChannelArray.
virtual void channelDisconnect(bool destroy)
Notification when underlying Channel becomes DISCONNECTED or DESTORYED.
Notifications associated with Channel::createChannelRPC()
virtual ChannelProvider::shared_pointer newInstance()
Create a new instance using the default Configuration.
virtual void printInfo()
Prints detailed information about the context to the standard output stream.
Helper for ChannelProviders which access a singleton resource (eg.
void replace(_ForwardIterator __first, _ForwardIterator __last, const _Tp &__old_value, const _Tp &__new_value)