changes for 1.2.5

This commit is contained in:
Guenter Obiltschnig
2006-10-23 15:33:11 +00:00
parent 5638037326
commit 072ba74f28
35 changed files with 276 additions and 184 deletions

View File

@@ -1,7 +1,7 @@
//
// AbstractCache.h
//
// $Id: //poco/1.2/Foundation/include/Poco/AbstractCache.h#3 $
// $Id: //poco/1.2/Foundation/include/Poco/AbstractCache.h#4 $
//
// Library: Foundation
// Package: Cache
@@ -124,6 +124,25 @@ public:
doClear();
}
std::size_t size() const
/// Returns the number of cached elements
{
FastMutex::ScopedLock lock(_mutex);
return _data.size();
}
void forceReplace()
/// Forces cache replacement. Note that Poco's cache strategy use for efficiency reason no background thread
/// which periodically triggers cache replacement. Cache Replacement is only started when the cache is modified
/// from outside, i.e. add is called, or when a user tries to access an cache element via get.
/// In some cases, i.e. expire based caching where for a long time no access to the cache happens,
/// it might be desirable to be able to trigger cache replacement manually.
{
FastMutex::ScopedLock lock(_mutex);
doReplace();
}
protected:
mutable BasicEvent<ValidArgs<TKey> > IsValid;
mutable BasicEvent<KeySet> Replace;

View File

@@ -1,7 +1,7 @@
//
// AbstractDelegate.h
//
// $Id: //poco/1.2/Foundation/include/Poco/AbstractDelegate.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/AbstractDelegate.h#2 $
//
// Library: Foundation
// Package: Events
@@ -54,8 +54,14 @@ class AbstractDelegate
/// instead of run-time checks.
{
public:
AbstractDelegate()
AbstractDelegate(void* pTarget): _pTarget(pTarget)
{
poco_assert_dbg (_pTarget != 0);
}
AbstractDelegate(const AbstractDelegate& del):_pTarget(del._pTarget)
{
poco_assert_dbg (_pTarget != 0);
}
virtual ~AbstractDelegate()
@@ -68,8 +74,19 @@ public:
virtual AbstractDelegate* clone() const = 0;
/// Returns a deep-copy of the AbstractDelegate
virtual bool operator < (const AbstractDelegate<TArgs>& other) const = 0;
bool operator < (const AbstractDelegate<TArgs>& other) const
/// For comparing AbstractDelegates in a collection.
{
return _pTarget < other._pTarget;
}
void* target() const
{
return _pTarget;
}
protected:
void* _pTarget;
};

View File

@@ -1,7 +1,7 @@
//
// AbstractEvent.h
//
// $Id: //poco/1.2/Foundation/include/Poco/AbstractEvent.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/AbstractEvent.h#3 $
//
// Library: Foundation
// Package: Events
@@ -211,7 +211,7 @@ public:
/// the next notify. If one of the delegates throws an exception, the execution
/// is aborted and the exception is reported to the caller.
{
NotifyAsyncParams params;
NotifyAsyncParams params(pSender, args);
{
FastMutex::ScopedLock lock(_mutex);
@@ -223,8 +223,6 @@ public:
// between notifyAsync and the execution of the method no changes can occur
params.ptrStrat = SharedPtr<TStrategy>(new TStrategy(_strategy));
params.pSender = pSender;
params.args = args;
params.enabled = _enabled;
}
@@ -267,7 +265,13 @@ protected:
const void* pSender;
TArgs args;
bool enabled;
NotifyAsyncParams(const void* pSend, const TArgs& a):ptrStrat(), pSender(pSend), args(a), enabled(true)
/// default constructor reduces the need for TArgs to have an empty constructor, only copy constructor is needed.
{
}
};
ActiveMethod<TArgs, NotifyAsyncParams, AbstractEvent> _executeAsync;
TArgs executeAsyncImpl(const NotifyAsyncParams& par)
@@ -278,7 +282,7 @@ protected:
}
NotifyAsyncParams params = par;
TArgs retArgs = params.args;
TArgs retArgs(params.args);
params.ptrStrat->notify(params.pSender, retArgs);
return retArgs;
}

View File

@@ -1,7 +1,7 @@
//
// AbstractPriorityDelegate.h
//
// $Id: //poco/1.2/Foundation/include/Poco/AbstractPriorityDelegate.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/AbstractPriorityDelegate.h#2 $
//
// Library: Foundation
// Package: Events
@@ -54,7 +54,15 @@ class AbstractPriorityDelegate
/// instead of run-time checks.
{
public:
AbstractPriorityDelegate()
AbstractPriorityDelegate(void* pTarget, int prio):
_pTarget(pTarget),
_priority(prio)
{
}
AbstractPriorityDelegate(const AbstractPriorityDelegate& del):
_pTarget(del._pTarget),
_priority(del._priority)
{
}
@@ -68,8 +76,30 @@ public:
virtual AbstractPriorityDelegate* clone() const = 0;
// Returns a deep-copy of the object.
virtual bool operator < (const AbstractPriorityDelegate<TArgs>& other) const = 0;
bool operator < (const AbstractPriorityDelegate<TArgs>& other) const
/// Operator used for comparing AbstractPriorityDelegates in a collection.
{
if (_priority == other._priority)
{
return _pTarget < other._pTarget;
}
return (_priority < other._priority);
}
void* target() const
{
return _pTarget;
}
int priority() const
{
return _priority;
}
protected:
void* _pTarget;
int _priority;
};

View File

@@ -1,7 +1,7 @@
//
// Delegate.h
//
// $Id: //poco/1.2/Foundation/include/Poco/Delegate.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/Delegate.h#3 $
//
// Library: Foundation
// Package: Events
@@ -55,12 +55,14 @@ public:
typedef void (TObj::*NotifyMethod)(const void*, TArgs&);
Delegate(TObj* obj, NotifyMethod method):
AbstractDelegate<TArgs>(obj),
_receiverObject(obj),
_receiverMethod(method)
{
}
Delegate(const Delegate& delegate):
AbstractDelegate<TArgs>(delegate),
_receiverObject(delegate._receiverObject),
_receiverMethod(delegate._receiverMethod)
{
@@ -74,8 +76,9 @@ public:
{
if (&delegate != this)
{
_receiverObject = delegate._receiverObject;
_receiverMethod = delegate._receiverMethod;
this->_pTarget = delegate._pTarget;
this->_receiverObject = delegate._receiverObject;
this->_receiverMethod = delegate._receiverMethod;
}
return *this;
}
@@ -91,20 +94,6 @@ public:
return new Delegate(*this);
}
bool operator < (const AbstractDelegate<TArgs>& other) const
{
const Delegate<TObj, TArgs>* pOther = dynamic_cast<const Delegate<TObj, TArgs>*>(&other);
if (pOther == 0)
{
const Expire<TArgs>* pExpire = dynamic_cast<const Expire<TArgs>*>(&other);
poco_check_ptr(pExpire);
return this->operator < (pExpire->getDelegate());
}
return _receiverObject < pOther->_receiverObject;
}
protected:
TObj* _receiverObject;
NotifyMethod _receiverMethod;

View File

@@ -1,7 +1,7 @@
//
// EventLogChannel.h
//
// $Id: //poco/1.2/Foundation/include/Poco/EventLogChannel.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/EventLogChannel.h#2 $
//
// Library: Foundation
// Package: Logging
@@ -88,16 +88,18 @@ public:
///
/// The following properties are supported:
///
/// * name: The name of the event source.
/// * host: The name of the host where the Event Log service is running.
/// The default is "localhost".
/// * logFile: The name of the log file. The default is "Application".
/// * name: The name of the event source.
/// * loghost: The name of the host where the Event Log service is running.
/// The default is "localhost".
/// * host: same as host.
/// * logfile: The name of the log file. The default is "Application".
std::string getProperty(const std::string& name) const;
/// Returns the value of the given property.
static const std::string PROP_NAME;
static const std::string PROP_HOST;
static const std::string PROP_LOGHOST;
static const std::string PROP_LOGFILE;
protected:

View File

@@ -1,7 +1,7 @@
//
// Expire.h
//
// $Id: //poco/1.2/Foundation/include/Poco/Expire.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/Expire.h#2 $
//
// Library: Foundation
// Package: Events
@@ -55,12 +55,14 @@ class Expire: public AbstractDelegate<TArgs>
{
public:
Expire(const AbstractDelegate<TArgs>& p, Timestamp::TimeDiff expireMillisecs):
AbstractDelegate<TArgs>(p),
_pDelegate(p.clone()),
_expire(expireMillisecs*1000)
{
}
Expire(const Expire& expire):
AbstractDelegate<TArgs>(expire),
_pDelegate(expire._pDelegate->clone()),
_expire(expire._expire),
_creationTime(expire._creationTime)
@@ -76,10 +78,11 @@ public:
{
if (&expire != this)
{
delete _pDelegate;
_pDelegate = expire._pDelegate->clone();
_expire = expire._expire;
_creationTime = expire._creationTime;
delete this->_pDelegate;
this->_pDelegate = expire._pDelegate->clone();
this->_expire = expire._expire;
this->_creationTime = expire._creationTime;
this->_pTarget = expire._pTarget;
}
return *this;
}
@@ -87,7 +90,7 @@ public:
bool notify(const void* sender, TArgs& arguments)
{
if (!expired())
return _pDelegate->notify(sender, arguments);
return this->_pDelegate->notify(sender, arguments);
else
return false;
}
@@ -97,34 +100,18 @@ public:
return new Expire(*this);
}
bool operator < (const AbstractDelegate<TArgs>& other) const
{
const Expire* pOther = dynamic_cast<const Expire*>(&other);
if (pOther)
return _pDelegate->operator < (*pOther->_pDelegate);
else
return _pDelegate->operator < (other);
}
void destroy()
{
delete _pDelegate;
_pDelegate = 0;
delete this->_pDelegate;
this->_pDelegate = 0;
}
const AbstractDelegate<TArgs>& getDelegate() const
{
return *_pDelegate;
return *this->_pDelegate;
}
protected:
Expire(AbstractDelegate<TArgs>* p, Timestamp::TimeDiff expireMillisecs):
_pDelegate(p),
_expire(expireMillisecs*1000)
{
}
bool expired() const
{
return _creationTime.isElapsed(_expire);

View File

@@ -1,7 +1,7 @@
//
// ExpireLRUCache.h
//
// $Id: //poco/1.2/Foundation/include/Poco/ExpireLRUCache.h#3 $
// $Id: //poco/1.2/Foundation/include/Poco/ExpireLRUCache.h#4 $
//
// Library: Foundation
// Package: Cache
@@ -54,7 +54,7 @@ template <
class TValue
>
class ExpireLRUCache: public AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue> >
/// An ExpireLRUCache combines LUR caching and time based expire caching.
/// An ExpireLRUCache combines LRU caching and time based expire caching.
/// It cache entries for a fixed time period (per default 10 minutes)
/// but also limits the size of the cache (per default: 1024).
{

View File

@@ -1,7 +1,7 @@
//
// LRUCache.h
//
// $Id: //poco/1.2/Foundation/include/Poco/LRUCache.h#3 $
// $Id: //poco/1.2/Foundation/include/Poco/LRUCache.h#4 $
//
// Library: Foundation
// Package: Cache
@@ -49,7 +49,7 @@ namespace Poco {
template <class TKey, class TValue>
class LRUCache: public AbstractCache<TKey, TValue, LRUStrategy<TKey, TValue> >
/// An LRUCache is the interface of all caches.
/// An LRUCache implements Least Recently Used caching. The default size for a cache is 1024 entries
{
public:
LRUCache(long size = 1024):

View File

@@ -1,7 +1,7 @@
//
// Logger.h
//
// $Id: //poco/1.2/Foundation/include/Poco/Logger.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/Logger.h#2 $
//
// Library: Foundation
// Package: Logging
@@ -241,10 +241,24 @@ public:
/// Attaches the given Channel to all loggers that are
/// descendants of the Logger with the given name.
static void setProperty(const std::string& loggerName, const std::string& propertyName, const std::string& value);
/// Sets or changes a configuration property for all loggers
/// that are descendants of the Logger with the given name.
static Logger& get(const std::string& name);
/// Returns a reference to the Logger with the given name.
/// If the Logger does not yet exist, it is created, based
/// on its parent logger.
static Logger& unsafeGet(const std::string& name);
/// Returns a reference to the Logger with the given name.
/// If the Logger does not yet exist, it is created, based
/// on its parent logger.
///
/// WARNING: This method is not thread safe. You should
/// probably use get() instead.
/// The only time this method should be used is during
/// program initialization, when only one thread is running.
static Logger& create(const std::string& name, Channel* pChannel, int level = Message::PRIO_INFORMATION);
/// Creates and returns a reference to a Logger with the
@@ -274,6 +288,8 @@ public:
/// Fills the given vector with the names
/// of all currently defined loggers.
static const std::string ROOT; /// The name of the root logger ("").
protected:
typedef std::map<std::string, Logger*> LoggerMap;
@@ -286,6 +302,7 @@ protected:
static void formatDump(std::string& message, const void* buffer, int length);
static Logger& parent(const std::string& name);
static void add(Logger* pLogger);
static Logger* find(const std::string& name);
private:
Logger();

View File

@@ -1,7 +1,7 @@
//
// PriorityDelegate.h
//
// $Id: //poco/1.2/Foundation/include/Poco/PriorityDelegate.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/PriorityDelegate.h#3 $
//
// Library: Foundation
// Package: Events
@@ -54,17 +54,17 @@ class PriorityDelegate: public AbstractPriorityDelegate<TArgs>
public:
typedef void (TObj::*NotifyMethod)(const void*, TArgs&);
PriorityDelegate(TObj* obj, NotifyMethod method, int prio):
_receiverObject(obj),
_receiverMethod(method),
_priority(prio)
PriorityDelegate(TObj* obj, NotifyMethod method, int prio):
AbstractPriorityDelegate<TArgs>(obj, prio),
_receiverObject(obj),
_receiverMethod(method)
{
}
PriorityDelegate(const PriorityDelegate& delegate):
AbstractPriorityDelegate<TArgs>(delegate._pTarget, delegate._priority),
_receiverObject(delegate._receiverObject),
_receiverMethod(delegate._receiverMethod),
_priority(delegate._priority)
_receiverMethod(delegate._receiverMethod)
{
}
@@ -72,9 +72,10 @@ public:
{
if (&delegate != this)
{
_receiverObject = delegate._receiverObject;
_receiverMethod = delegate._receiverMethod;
_priority = delegate._priority;
this->_pTarget = delegate._pTarget;
this->_receiverObject = delegate._receiverObject;
this->_receiverMethod = delegate._receiverMethod;
this->_priority = delegate._priority;
}
return *this;
}
@@ -94,35 +95,9 @@ public:
return new PriorityDelegate(*this);
}
bool operator < (const AbstractPriorityDelegate<TArgs>& other) const
{
const PriorityDelegate* pOther = dynamic_cast<const PriorityDelegate*>(&other);
if (pOther == 0)
{
const PriorityExpire<TArgs>* pExpire = dynamic_cast<const PriorityExpire<TArgs>*>(&other);
poco_check_ptr(pExpire);
return this->operator < (pExpire->getDelegate());
}
if (_priority < pOther->_priority)
{
return true;
}
if (_priority > pOther->_priority)
{
return false;
}
return _receiverObject < pOther->_receiverObject;
}
protected:
TObj* _receiverObject;
NotifyMethod _receiverMethod;
int _priority;
private:
PriorityDelegate();

View File

@@ -1,7 +1,7 @@
//
// PriorityExpire.h
//
// $Id: //poco/1.2/Foundation/include/Poco/PriorityExpire.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/PriorityExpire.h#2 $
//
// Library: Foundation
// Package: Events
@@ -54,13 +54,15 @@ class PriorityExpire: public AbstractPriorityDelegate<TArgs>
/// expiring of registrations to AbstractPriorityDelegate.
{
public:
PriorityExpire(const AbstractPriorityDelegate<TArgs>& p, Timestamp::TimeDiff expireMilliSec):
PriorityExpire(const AbstractPriorityDelegate<TArgs>& p, Timestamp::TimeDiff expireMilliSec):
AbstractPriorityDelegate<TArgs>(p),
_pDelegate(p.clone()),
_expire(expireMilliSec*1000)
{
}
PriorityExpire(const PriorityExpire& expire):
AbstractPriorityDelegate<TArgs>(expire),
_pDelegate(expire._pDelegate->clone()),
_expire(expire._expire),
_creationTime(expire._creationTime)
@@ -76,10 +78,11 @@ public:
{
if (&expire != this)
{
delete _pDelegate;
_pDelegate = expire._pDelegate->clone();
_expire = expire._expire;
_creationTime = expire._creationTime;
delete this->_pDelegate;
this->_pTarget = expire._pTarget;
this->_pDelegate = expire._pDelegate->clone();
this->_expire = expire._expire;
this->_creationTime = expire._creationTime;
}
return *this;
}
@@ -87,7 +90,7 @@ public:
bool notify(const void* sender, TArgs& arguments)
{
if (!expired())
return _pDelegate->notify(sender, arguments);
return this->_pDelegate->notify(sender, arguments);
else
return false;
}
@@ -97,34 +100,18 @@ public:
return new PriorityExpire(*this);
}
bool operator < (const AbstractPriorityDelegate<TArgs>& other) const
{
const PriorityExpire<TArgs>* pOther = dynamic_cast<const PriorityExpire<TArgs>*>(&other);
if (pOther)
return _pDelegate->operator < (*pOther->_pDelegate);
else
return _pDelegate->operator < (other);
}
void destroy()
{
delete _pDelegate;
_pDelegate = 0;
delete this->_pDelegate;
this->_pDelegate = 0;
}
const AbstractPriorityDelegate<TArgs>& getDelegate() const
{
return *_pDelegate;
return *this->_pDelegate;
}
protected:
PriorityExpire(AbstractPriorityDelegate<TArgs>* p, Timestamp::TimeDiff expireMilliSec):
_pDelegate(p),
_expire(expireMilliSec*1000)
{
}
bool expired() const
{
return _creationTime.isElapsed(_expire);

View File

@@ -1,7 +1,7 @@
//
// SplitterChannel.h
//
// $Id: //poco/1.2/Foundation/include/Poco/SplitterChannel.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/SplitterChannel.h#2 $
//
// Library: Foundation
// Package: Logging
@@ -71,7 +71,7 @@ public:
/// Sets or changes a configuration property.
///
/// Only the "channel" property is supported, which allows
/// adding a channel via the LoggingRegistry.
/// adding a comma-separated list of channels via the LoggingRegistry.
/// The "channel" property is set-only.
/// To simplify file-based configuration, all property
/// names starting with "channel" are treated as "channel".