cleanup cntd.
This commit is contained in:
@@ -8,13 +8,15 @@
|
||||
#ifndef INETADDRESSUTIL_H_
|
||||
#define INETADDRESSUTIL_H_
|
||||
|
||||
// review this header, is it needed, use pure libCom calls?
|
||||
|
||||
/* uporabim lahko:
|
||||
* EPICSv3 osiSock.h kjer je definiran osiSockDiscoverBroadcastAddresses
|
||||
*
|
||||
* Kako se ga uporablja je v
|
||||
* epics/base/src/ca/iocinf.cpp funkcija configureChannelAccessAddressList
|
||||
*
|
||||
* razišči kako se to priredi za IPv6
|
||||
* razisci kako se to priredi za IPv6
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -23,8 +25,6 @@
|
||||
#include <osiSock.h>
|
||||
#include <vector>
|
||||
|
||||
using namespace epics::pvData;
|
||||
|
||||
namespace epics {
|
||||
namespace pvAccess {
|
||||
|
||||
@@ -46,21 +46,21 @@ namespace epics {
|
||||
* @param address address to encode.
|
||||
*/
|
||||
void
|
||||
encodeAsIPv6Address(ByteBuffer* buffer, const osiSockAddr* address);
|
||||
encodeAsIPv6Address(epics::pvData::ByteBuffer* buffer, const osiSockAddr* address);
|
||||
|
||||
/**
|
||||
* Convert an integer into an IPv4 INET address.
|
||||
* @param addr integer representation of a given address.
|
||||
* @return IPv4 INET address.
|
||||
*/
|
||||
osiSockAddr* intToIPv4Address(int32 addr);
|
||||
osiSockAddr* intToIPv4Address(epics::pvData::int32 addr);
|
||||
|
||||
/**
|
||||
* Convert an IPv4 INET address to an integer.
|
||||
* @param addr IPv4 INET address.
|
||||
* @return integer representation of a given address.
|
||||
*/
|
||||
int32 ipv4AddressToInt(const osiSockAddr& addr);
|
||||
epics::pvData::int32 ipv4AddressToInt(const osiSockAddr& addr);
|
||||
|
||||
/**
|
||||
* Parse space delimited addresss[:port] string and return array of <code>InetSocketAddress</code>.
|
||||
@@ -69,10 +69,10 @@ namespace epics {
|
||||
* @param appendList list to be appended.
|
||||
* @return array of <code>InetSocketAddress</code>.
|
||||
*/
|
||||
InetAddrVector* getSocketAddressList(String list, int defaultPort,
|
||||
InetAddrVector* getSocketAddressList(epics::pvData::String list, int defaultPort,
|
||||
const InetAddrVector* appendList = NULL);
|
||||
|
||||
const String inetAddressToString(const osiSockAddr *addr,
|
||||
const epics::pvData::String inetAddressToString(const osiSockAddr *addr,
|
||||
bool displayPort = true, bool displayHex = false);
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
// TODO check for memory leaks
|
||||
// TODO to be removed out of header
|
||||
using namespace epics::pvData;
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -13,14 +13,11 @@
|
||||
|
||||
#include "referenceCountingLock.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace epics::pvData;
|
||||
|
||||
namespace epics { namespace pvAccess {
|
||||
/**
|
||||
* NamedLockPattern
|
||||
*/
|
||||
template <class Key, class Compare = less<Key> >
|
||||
template <class Key, class Compare = std::less<Key> >
|
||||
class NamedLockPattern
|
||||
{
|
||||
public:
|
||||
@@ -44,14 +41,14 @@ public:
|
||||
* @return <code>true</code> if acquired, <code>false</code> othwerwise.
|
||||
* NOTE: currently this routine always returns true. Look above for explanation.
|
||||
*/
|
||||
bool acquireSynchronizationObject(const Key name, const int64 msec);
|
||||
bool acquireSynchronizationObject(const Key name, const epics::pvData::int64 msec);
|
||||
/**
|
||||
* Release synchronization lock for named object.
|
||||
* @param name name of the object whose lock to release.
|
||||
*/
|
||||
void releaseSynchronizationObject(const Key name);
|
||||
private:
|
||||
Mutex _mutex;
|
||||
epics::pvData::Mutex _mutex;
|
||||
std::map<const Key,ReferenceCountingLock*,Compare> _namedLocks;
|
||||
typename std::map<const Key,ReferenceCountingLock*,Compare>::iterator _namedLocksIter;
|
||||
|
||||
@@ -65,11 +62,11 @@ private:
|
||||
};
|
||||
|
||||
template <class Key, class Compare>
|
||||
bool NamedLockPattern<Key,Compare>::acquireSynchronizationObject(const Key name, const int64 msec)
|
||||
bool NamedLockPattern<Key,Compare>::acquireSynchronizationObject(const Key name, const epics::pvData::int64 msec)
|
||||
{
|
||||
ReferenceCountingLock* lock;
|
||||
{ //due to guard
|
||||
Lock guard(&_mutex);
|
||||
epics::pvData::Lock guard(&_mutex);
|
||||
|
||||
_namedLocksIter = _namedLocks.find(name);
|
||||
// get synchronization object
|
||||
@@ -107,7 +104,7 @@ void NamedLockPattern<Key,Compare>::releaseSynchronizationObject(const Key name)
|
||||
template <class Key, class Compare>
|
||||
void NamedLockPattern<Key,Compare>::releaseSynchronizationObject(const Key name,const bool release)
|
||||
{
|
||||
Lock guard(&_mutex);
|
||||
epics::pvData::Lock guard(&_mutex);
|
||||
ReferenceCountingLock* lock;
|
||||
_namedLocksIter = _namedLocks.find(name);
|
||||
|
||||
@@ -133,11 +130,11 @@ void NamedLockPattern<Key,Compare>::releaseSynchronizationObject(const Key name,
|
||||
}
|
||||
|
||||
template <class Key, class Compare>
|
||||
class NamedLock : private NoDefaultMethods
|
||||
class NamedLock : private epics::pvData::NoDefaultMethods
|
||||
{
|
||||
public:
|
||||
NamedLock(NamedLockPattern<Key,Compare>* namedLockPattern): _namedLockPattern(namedLockPattern) {}
|
||||
bool acquireSynchronizationObject(const Key name, const int64 msec) {_name = name; return _namedLockPattern->acquireSynchronizationObject(name,msec);}
|
||||
bool acquireSynchronizationObject(const Key name, const epics::pvData::int64 msec) {_name = name; return _namedLockPattern->acquireSynchronizationObject(name,msec);}
|
||||
~NamedLock(){_namedLockPattern->releaseSynchronizationObject(_name);}
|
||||
private:
|
||||
Key _name;
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
namespace epics { namespace pvAccess {
|
||||
|
||||
using namespace epics::pvData;
|
||||
|
||||
ReferenceCountingLock::ReferenceCountingLock(): _references(1)
|
||||
{
|
||||
/* pthread_mutexattr_t mutexAttribute;
|
||||
|
||||
@@ -5,18 +5,8 @@
|
||||
#ifndef REFERENCECOUNTINGLOCK_H
|
||||
#define REFERENCECOUNTINGLOCK_H
|
||||
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
#include <pthread.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <lock.h>
|
||||
#include <pvType.h>
|
||||
#include <epicsAssert.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace epics::pvData;
|
||||
|
||||
namespace epics { namespace pvAccess {
|
||||
|
||||
@@ -53,7 +43,7 @@ public:
|
||||
* NOTE: currently this routine always returns true. Look above for explanation.
|
||||
*
|
||||
*/
|
||||
bool acquire(int64 msecs);
|
||||
bool acquire(epics::pvData::int64 msecs);
|
||||
/**
|
||||
* Release previously acquired lock.
|
||||
*/
|
||||
@@ -72,10 +62,8 @@ public:
|
||||
int decrement();
|
||||
private:
|
||||
int _references;
|
||||
Mutex _mutex;
|
||||
Mutex _countMutex;
|
||||
//pthread_mutex_t _mutex;
|
||||
|
||||
epics::pvData::Mutex _mutex;
|
||||
epics::pvData::Mutex _countMutex;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
#include "transportRegistry.h"
|
||||
|
||||
using namespace epics::pvData;
|
||||
using namespace std;
|
||||
|
||||
namespace epics { namespace pvAccess {
|
||||
|
||||
TransportRegistry::TransportRegistry(): _mutex(Mutex())
|
||||
@@ -18,14 +21,8 @@ TransportRegistry::~TransportRegistry()
|
||||
|
||||
void TransportRegistry::put(Transport* transport)
|
||||
{
|
||||
// TODO support type
|
||||
if(transport == NULL)
|
||||
{
|
||||
throw EpicsException("null transport provided");
|
||||
}
|
||||
|
||||
Lock guard(&_mutex);
|
||||
//const string type = transport.getType();
|
||||
//const String type = transport.getType();
|
||||
const int16 priority = transport->getPriority();
|
||||
const osiSockAddr* address = transport->getRemoteAddress();
|
||||
|
||||
@@ -44,14 +41,8 @@ void TransportRegistry::put(Transport* transport)
|
||||
_allTransports.push_back(transport);
|
||||
}
|
||||
|
||||
Transport* TransportRegistry::get(const string type, const osiSockAddr* address, const int16 priority)
|
||||
Transport* TransportRegistry::get(const String type, const osiSockAddr* address, const int16 priority)
|
||||
{
|
||||
// TODO support type
|
||||
if(address == NULL)
|
||||
{
|
||||
throw EpicsException("null address provided");
|
||||
}
|
||||
|
||||
Lock guard(&_mutex);
|
||||
_transportsIter = _transports.find(address);
|
||||
if(_transportsIter != _transports.end())
|
||||
@@ -66,14 +57,8 @@ Transport* TransportRegistry::get(const string type, const osiSockAddr* address,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Transport** TransportRegistry::get(const string type, const osiSockAddr* address, int32& size)
|
||||
Transport** TransportRegistry::get(const String type, const osiSockAddr* address, int32& size)
|
||||
{
|
||||
// TODO support type
|
||||
if(address == NULL)
|
||||
{
|
||||
throw EpicsException("null address provided");
|
||||
}
|
||||
|
||||
Lock guard(&_mutex);
|
||||
_transportsIter = _transports.find(address);
|
||||
if(_transportsIter != _transports.end())
|
||||
@@ -93,12 +78,6 @@ Transport** TransportRegistry::get(const string type, const osiSockAddr* address
|
||||
|
||||
Transport* TransportRegistry::remove(Transport* transport)
|
||||
{
|
||||
// TODO support type
|
||||
if(transport == NULL)
|
||||
{
|
||||
throw EpicsException("null transport provided");
|
||||
}
|
||||
|
||||
Lock guard(&_mutex);
|
||||
const int16 priority = transport->getPriority();
|
||||
const osiSockAddr* address = transport->getRemoteAddress();
|
||||
@@ -148,7 +127,7 @@ int TransportRegistry::numberOfActiveTransports()
|
||||
return (int32)_allTransports.size();
|
||||
}
|
||||
|
||||
Transport** TransportRegistry::toArray(const string type, int32& size)
|
||||
Transport** TransportRegistry::toArray(const String type, int32& size)
|
||||
{
|
||||
// TODO support type
|
||||
Lock guard(&_mutex);
|
||||
|
||||
@@ -8,25 +8,21 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <epicsMutex.h>
|
||||
|
||||
#include <osiSock.h>
|
||||
|
||||
#include "lock.h"
|
||||
#include "pvType.h"
|
||||
#include "epicsException.h"
|
||||
#include <lock.h>
|
||||
#include <pvType.h>
|
||||
#include <epicsException.h>
|
||||
#include <remote.h>
|
||||
#include "inetAddressUtil.h"
|
||||
#include "remote.h"
|
||||
|
||||
using namespace epics::pvData;
|
||||
using namespace std;
|
||||
|
||||
namespace epics { namespace pvAccess {
|
||||
|
||||
class Transport;
|
||||
//TODO if unordered map is used instead of map we can use sockAddrAreIdentical routine from osiSock.h
|
||||
|
||||
typedef std::map<const int16,Transport*> prioritiesMap_t;
|
||||
typedef std::map<const epics::pvData::int16,Transport*> prioritiesMap_t;
|
||||
typedef std::map<const osiSockAddr*,prioritiesMap_t*,comp_osiSockAddr> transportsMap_t;
|
||||
typedef std::vector<Transport*> allTransports_t;
|
||||
|
||||
@@ -36,13 +32,13 @@ typedef std::vector<Transport*> allTransports_t;
|
||||
virtual ~TransportRegistry();
|
||||
|
||||
void put(Transport* transport);
|
||||
Transport* get(const string type, const osiSockAddr* address, const int16 priority);
|
||||
Transport** get(const string type, const osiSockAddr* address, int32& size);
|
||||
Transport* get(const epics::pvData::String type, const osiSockAddr* address, const epics::pvData::int16 priority);
|
||||
Transport** get(const epics::pvData::String type, const osiSockAddr* address, epics::pvData::int32& size);
|
||||
Transport* remove(Transport* transport);
|
||||
void clear();
|
||||
int32 numberOfActiveTransports();
|
||||
Transport** toArray(const string type, int32& size);
|
||||
Transport** toArray(int32& size);
|
||||
epics::pvData::int32 numberOfActiveTransports();
|
||||
Transport** toArray(const epics::pvData::String type, epics::pvData::int32& size);
|
||||
Transport** toArray(epics::pvData::int32& size);
|
||||
|
||||
private:
|
||||
transportsMap_t _transports;
|
||||
@@ -50,7 +46,7 @@ typedef std::vector<Transport*> allTransports_t;
|
||||
prioritiesMap_t::iterator _prioritiesIter;
|
||||
allTransports_t _allTransports;
|
||||
allTransports_t::iterator _allTransportsIter;
|
||||
Mutex _mutex;
|
||||
epics::pvData::Mutex _mutex;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Author: Miha Vitorovic
|
||||
*/
|
||||
|
||||
#include "growingCircularBuffer.h"
|
||||
#include <growingCircularBuffer.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <epicsAssert.h>
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
* Author: user
|
||||
*/
|
||||
|
||||
#include "inetAddressUtil.h"
|
||||
#include "logger.h"
|
||||
#include <inetAddressUtil.h>
|
||||
#include <logger.h>
|
||||
|
||||
#include <byteBuffer.h>
|
||||
#include <pvType.h>
|
||||
@@ -17,11 +17,9 @@
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
|
||||
using namespace epics::pvData;
|
||||
using namespace epics::pvAccess;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
using std::stringstream;
|
||||
using std::hex;
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
createFileLogger("inetAddresUtils.log");
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Author: Miha Vitorovic
|
||||
*/
|
||||
|
||||
#include "logger.h"
|
||||
#include <logger.h>
|
||||
|
||||
#include <errlog.h>
|
||||
#include <epicsExit.h>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <osiSock.h>
|
||||
|
||||
using namespace epics::pvData;
|
||||
using namespace epics::pvAccess;
|
||||
using namespace std;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user