7 #ifndef CHANNELSEARCHMANAGER_H
8 #define CHANNELSEARCHMANAGER_H
10 #ifdef epicsExportSharedSymbols
11 # define channelSearchManagerEpicsExportSharedSymbols
12 # undef epicsExportSharedSymbols
17 #ifdef channelSearchManagerEpicsExportSharedSymbols
18 # define epicsExportSharedSymbols
19 # undef channelSearchManagerEpicsExportSharedSymbols
22 #include <pv/pvaDefs.h>
23 #include <pv/remote.h>
28 class SearchInstance {
30 POINTER_DEFINITIONS(SearchInstance);
35 virtual ~SearchInstance() {}
37 virtual pvAccessID getSearchInstanceID() = 0;
39 virtual const std::string& getSearchInstanceName() = 0;
41 virtual int32_t& getUserValue() = 0;
50 virtual void searchResponse(
const ServerGUID & guid, int8_t minorRevision, osiSockAddr* serverAddress) = 0;
54 class ChannelSearchManager :
55 public epics::pvData::TimerCallback,
56 public std::tr1::enable_shared_from_this<ChannelSearchManager>
59 POINTER_DEFINITIONS(ChannelSearchManager);
61 virtual ~ChannelSearchManager();
70 int32_t registeredCount();
75 void registerSearchInstance(SearchInstance::shared_pointer
const & channel,
bool penalize =
false);
80 void unregisterSearchInstance(SearchInstance::shared_pointer
const & channel);
89 void searchResponse(
const ServerGUID & guid, pvAccessID cid, int32_t seqNo, int8_t minorRevision, osiSockAddr* serverAddress);
94 void newServerDetected();
97 virtual void callback() OVERRIDE FINAL;
100 virtual
void timerStopped() OVERRIDE FINAL;
106 ChannelSearchManager(Context::shared_pointer const & context);
111 bool generateSearchRequestMessage(SearchInstance::shared_pointer const & channel,
bool allowNewFrame,
bool flush);
113 static
bool generateSearchRequestMessage(SearchInstance::shared_pointer const & channel,
114 epics::pvData::ByteBuffer* byteBuffer, TransportSendControl* control);
118 void initializeSendBuffer();
119 void flushSendBuffer();
121 static
bool isPowerOfTwo(int32_t x);
126 Context::weak_pointer m_context;
131 osiSockAddr m_responseAddress;
136 AtomicBoolean m_canceled;
141 int32_t m_sequenceNumber;
146 epics::pvData::ByteBuffer m_sendBuffer;
151 typedef std::map<pvAccessID,SearchInstance::weak_pointer> m_channels_t;
152 m_channels_t m_channels;
157 int64_t m_lastTimeSent;
162 epics::pvData::Mutex m_channelMutex;
167 epics::pvData::Mutex m_userValueMutex;
172 epics::pvData::Mutex m_mutex;