changes for 1.2.4

This commit is contained in:
Guenter Obiltschnig
2006-09-29 14:39:00 +00:00
parent 245e2f7e83
commit 76edf6f35c
52 changed files with 1290 additions and 1056 deletions

View File

@@ -1,7 +1,7 @@
//
// AbstractCache.h
//
// $Id: //poco/1.2/Foundation/include/Poco/AbstractCache.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/AbstractCache.h#3 $
//
// Library: Foundation
// Package: Cache
@@ -70,12 +70,12 @@ public:
typedef typename DataHolder::const_iterator ConstIterator;
typedef std::set<TKey> KeySet;
AbstractCache()
AbstractCache()
{
initialize();
}
AbstractCache(const TStrategy& strat):_strategy(strat)
AbstractCache(const TStrategy& strat): _strategy(strat)
{
initialize();
}
@@ -84,7 +84,7 @@ public:
{
uninitialize();
}
void add(const TKey& key, const TValue& val)
/// Adds the key value pair to the cache.
/// If for the key already an entry exists, it will be overwritten.
@@ -92,7 +92,7 @@ public:
FastMutex::ScopedLock lock(_mutex);
doAdd(key, val);
}
void remove(const TKey& key)
/// Removes an entry from the cache. If the entry is not found,
/// the remove is ignored.
@@ -100,13 +100,13 @@ public:
FastMutex::ScopedLock lock(_mutex);
doRemove(key);
}
bool has(const TKey& key) const
/// Returns true if the cache contains a value for the key.
{
FastMutex::ScopedLock lock(_mutex);
return doHas(key);
}
}
SharedPtr<TValue> get(const TKey& key)
/// Returns a SharedPtr of the value. The SharedPointer will remain valid
@@ -116,7 +116,7 @@ public:
FastMutex::ScopedLock lock(_mutex);
return doGet (key);
}
void clear()
/// Removes all elements from the cache.
{
@@ -138,7 +138,7 @@ protected:
IsValid += Delegate<TStrategy, ValidArgs<TKey> >(&_strategy, &TStrategy::onIsValid);
Replace += Delegate<TStrategy, KeySet>(&_strategy, &TStrategy::onReplace);
}
void uninitialize()
/// Reverts event registration.
{
@@ -165,7 +165,7 @@ protected:
doReplace();
}
void doRemove(const TKey& key)
/// Removes an entry from the cache. If the entry is not found
/// the remove is ignored.
@@ -173,7 +173,7 @@ protected:
Remove.notify(this, key);
_data.erase(key);
}
bool doHas(const TKey& key) const
/// Returns true if the cache contains a value for the key
{
@@ -218,7 +218,7 @@ protected:
return result;
}
void doClear()
{
static EventArgs _emptyArgs;
@@ -244,7 +244,6 @@ protected:
mutable DataHolder _data;
mutable FastMutex _mutex;
private:
AbstractCache(const AbstractCache& aCache);
AbstractCache& operator = (const AbstractCache& aCache);

View File

@@ -1,7 +1,7 @@
//
// AbstractStrategy.h
//
// $Id: //poco/1.2/Foundation/include/Poco/AbstractStrategy.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/AbstractStrategy.h#2 $
//
// Library: Foundation
// Package: Cache
@@ -53,8 +53,8 @@ class AbstractStrategy
/// An AbstractStrategy is the interface for all strategies.
{
public:
AbstractStrategy()
{
AbstractStrategy()
{
}
virtual ~AbstractStrategy()
@@ -71,7 +71,7 @@ public:
virtual void onGet(const void* pSender, const TKey& key) = 0;
/// Informs the strategy that a read-access happens to an element.
virtual void onClear(const void* pSender, const EventArgs& args) = 0;
/// Removes all elements from the cache.

View File

@@ -1,7 +1,7 @@
//
// AutoPtr.h
//
// $Id: //poco/1.2/Foundation/include/Poco/AutoPtr.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/AutoPtr.h#2 $
//
// Library: Foundation
// Package: Core
@@ -151,18 +151,18 @@ public:
}
template <class Other>
AutoPtr < Other > cast()
AutoPtr<Other> cast()
/// Casts the AutoPtr via a dynamic cast to the given type.
/// Returns an AutoPtr containing NULL if the cast fails.
/// Example: (assume class Sub: public Super)
/// AutoPtr < Super > super(new Sub());
/// AutoPtr < Sub > sub = super.cast<Sub>();
/// AutoPtr<Super> super(new Sub());
/// AutoPtr<Sub> sub = super.cast<Sub>();
/// poco_assert (sub.get());
{
Other* pOther = dynamic_cast <Other*>(_ptr);
if (pOther)
pOther->duplicate();
return AutoPtr < Other > (pOther);
return AutoPtr<Other>(pOther);
}
C* operator -> ()
@@ -201,6 +201,11 @@ public:
{
return _ptr;
}
bool isNull() const
{
return _ptr == 0;
}
operator C* ()
{

View File

@@ -1,7 +1,7 @@
//
// ExpireCache.h
//
// $Id: //poco/1.2/Foundation/include/Poco/ExpireCache.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/ExpireCache.h#3 $
//
// Library: Foundation
// Package: Cache
@@ -48,7 +48,7 @@ namespace Poco {
template <class TKey, class TValue>
class ExpireCache: public AbstractCache<TKey, TValue, ExpireStrategy<TKey, TValue > >
class ExpireCache: public AbstractCache<TKey, TValue, ExpireStrategy<TKey, TValue> >
/// An ExpireCache caches entries for a fixed time period (per default 10 minutes)
/// Be careful when using an ExpireCache. A cache is often used
/// like cache.has(x) followed by cache.get x). Note that it could happen

View File

@@ -1,7 +1,7 @@
//
// ExpireLRUCache.h
//
// $Id: //poco/1.2/Foundation/include/Poco/ExpireLRUCache.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/ExpireLRUCache.h#3 $
//
// Library: Foundation
// Package: Cache
@@ -52,7 +52,7 @@ namespace Poco {
template <
class TKey,
class TValue
>
>
class ExpireLRUCache: public AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue> >
/// An ExpireLRUCache combines LUR caching and time based expire caching.
/// It cache entries for a fixed time period (per default 10 minutes)
@@ -66,10 +66,10 @@ public:
this->_strategy.pushBack(new ExpireStrategy<TKey, TValue>(expire));
}
virtual ~ExpireLRUCache()
~ExpireLRUCache()
{
}
private:
ExpireLRUCache(const ExpireLRUCache& aCache);
ExpireLRUCache& operator = (const ExpireLRUCache& aCache);

View File

@@ -1,7 +1,7 @@
//
// ExpireStrategy.h
//
// $Id: //poco/1.2/Foundation/include/Poco/ExpireStrategy.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/ExpireStrategy.h#2 $
//
// Library: Foundation
// Package: Cache
@@ -56,15 +56,15 @@ namespace Poco {
template <
class TKey,
class TValue
>
>
class ExpireStrategy: public AbstractStrategy<TKey, TValue>
/// An ExpireStrategy implements time based ecpiration of cache entries
/// An ExpireStrategy implements time based expiration of cache entries
{
public:
typedef std::multimap<Timestamp, TKey> TimeIndex;
typedef typename TimeIndex::iterator IndexIterator;
typedef typename TimeIndex::const_iterator ConstIndexIterator;
typedef std::map<TKey, IndexIterator> Keys;
typedef std::map<TKey, IndexIterator> Keys;
typedef typename Keys::iterator Iterator;
public:
@@ -75,7 +75,7 @@ public:
if (_expireTime < 25000) throw InvalidArgumentException("expireTime must be at least 25 ms");
}
virtual ~ExpireStrategy()
~ExpireStrategy()
{
}
@@ -83,7 +83,7 @@ public:
{
Timestamp now;
IndexIterator it = _keyIndex.insert(std::make_pair(now, args.key()));
std::pair < Iterator, bool > stat = _keys.insert(std::make_pair(args.key(), it));
std::pair<Iterator, bool> stat = _keys.insert(std::make_pair(args.key(), it));
if (!stat.second)
{
_keyIndex.erase(stat.first->second);
@@ -94,7 +94,7 @@ public:
void onRemove(const void*, const TKey& key)
{
Iterator it = _keys.find(key);
if (it != _keys.end ())
if (it != _keys.end())
{
_keyIndex.erase(it->second);
_keys.erase(it);
@@ -111,11 +111,11 @@ public:
_keys.clear();
_keyIndex.clear();
}
void onIsValid(const void*, ValidArgs<TKey>& args)
{
Iterator it = _keys.find(args.key());
if (it != _keys.end ())
if (it != _keys.end())
{
if (it->second->first.isElapsed(_expireTime))
{

View File

@@ -1,7 +1,7 @@
//
// Foundation.h
//
// $Id: //poco/1.2/Foundation/include/Poco/Foundation.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/Foundation.h#2 $
//
// Library: Foundation
// Package: Core
@@ -83,6 +83,7 @@
//
// Include platform-specific definitions
//
#include "Poco/Platform.h"
#if defined(_WIN32)
#include "Poco/Platform_WIN32.h"
#elif defined(__VMS)
@@ -95,7 +96,6 @@
//
// Pull in basic definitions
//
#include "Poco/Platform.h"
#include "Poco/Bugcheck.h"
#include "Poco/Types.h"
#include <string>

View File

@@ -1,7 +1,7 @@
//
// HashTable.h
//
// $Id: //poco/1.2/Foundation/include/Poco/HashTable.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/HashTable.h#2 $
//
// Library: Foundation
// Package: Core
@@ -172,7 +172,7 @@ public:
{
if (!_entries[hsh])
_entries[hsh] = new HashEntryMap();
std::pair < Iterator, bool > res = _entries[hsh]->insert(make_pair(key, value));
std::pair<Iterator, bool> res = _entries[hsh]->insert(make_pair(key, value));
if (res.second == false)
res.first->second = value;
else

View File

@@ -1,7 +1,7 @@
//
// KeyValueArgs.h
//
// $Id: //poco/1.2/Foundation/include/Poco/KeyValueArgs.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/KeyValueArgs.h#2 $
//
// Library: Foundation
// Package: Cache
@@ -68,7 +68,7 @@ public:
{
}
const TKey& key() const
const TKey& key() const
/// Returns a reference to the key,
{
return _key;
@@ -79,7 +79,7 @@ public:
{
return _value;
}
protected:
const TKey& _key;
const TValue& _value;

View File

@@ -1,7 +1,7 @@
//
// LRUCache.h
//
// $Id: //poco/1.2/Foundation/include/Poco/LRUCache.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/LRUCache.h#3 $
//
// Library: Foundation
// Package: Cache
@@ -51,14 +51,13 @@ template <class TKey, class TValue>
class LRUCache: public AbstractCache<TKey, TValue, LRUStrategy<TKey, TValue> >
/// An LRUCache is the interface of all caches.
{
public:
LRUCache(long size = 1024):
LRUCache(long size = 1024):
AbstractCache<TKey, TValue, LRUStrategy<TKey, TValue> >(LRUStrategy<TKey, TValue>(size))
{
{
}
virtual ~LRUCache()
~LRUCache()
{
}

View File

@@ -1,7 +1,7 @@
//
// LRUStrategy.h
//
// $Id: //poco/1.2/Foundation/include/Poco/LRUStrategy.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/LRUStrategy.h#2 $
//
// Library: Foundation
// Package: Cache
@@ -52,7 +52,7 @@
namespace Poco {
template <class TKey, class TValue>
template <class TKey, class TValue>
class LRUStrategy: public AbstractStrategy<TKey, TValue>
/// An LRUStrategy implements least recently used cache replacement.
{
@@ -71,14 +71,14 @@ public:
if (_size < 1) throw InvalidArgumentException("size must be > 0");
}
virtual ~LRUStrategy()
~LRUStrategy()
{
}
void onAdd(const void*, const KeyValueArgs <TKey, TValue>& args)
{
_keys.push_front(args.key());
std::pair < IndexIterator, bool > stat = _keyIndex.insert(make_pair(args.key(), _keys.begin()));
std::pair<IndexIterator, bool> stat = _keyIndex.insert(make_pair(args.key(), _keys.begin()));
if (!stat.second)
{
stat.first->second = _keys.begin();
@@ -135,7 +135,7 @@ public:
}
size_t diff = curSize - _size;
Iterator it = --_keys.end (); //--keys can never be invoked on an empty list due to the minSize==1 requirement of LRU
Iterator it = --_keys.end(); //--keys can never be invoked on an empty list due to the minSize==1 requirement of LRU
size_t i = 0;
while (i++ < diff)

View File

@@ -1,7 +1,7 @@
//
// SharedPtr.h
//
// $Id: //poco/1.2/Foundation/include/Poco/SharedPtr.h#2 $
// $Id: //poco/1.2/Foundation/include/Poco/SharedPtr.h#4 $
//
// Library: Foundation
// Package: Core
@@ -166,18 +166,18 @@ public:
}
template <class Other>
SharedPtr < Other > cast()
SharedPtr<Other> cast()
/// Casts the SharedPtr via a dynamic cast to the given type.
/// Returns an SharedPtr containing NULL if the cast fails.
/// Example: (assume class Sub: public Super)
/// SharedPtr < Super > super(new Sub());
/// SharedPtr < Sub > sub = super.cast<Sub>();
/// SharedPtr<Super> super(new Sub());
/// SharedPtr<Sub> sub = super.cast<Sub>();
/// poco_assert (sub.get());
{
Other* pOther = dynamic_cast <Other*>(_ptr);
if (pOther)
return SharedPtr < Other > (_pCounter, pOther);
return SharedPtr < Other > ();
return SharedPtr<Other> (_pCounter, pOther);
return SharedPtr<Other>();
}
void swap(SharedPtr& ptr)
@@ -212,7 +212,7 @@ public:
bool isNull() const
{
return (_ptr == 0);
return _ptr == 0;
}
operator C* ()
@@ -344,19 +344,18 @@ private:
}
}
SharedPtr(ReferenceCounter* pCounter, C* ptr):_pCounter(pCounter), _ptr(ptr)
SharedPtr(ReferenceCounter* pCounter, C* ptr): _pCounter(pCounter), _ptr(ptr)
/// for cast operation
{
poco_assert_dbg (_pCounter);
_pCounter->duplicate();
}
private:
ReferenceCounter* _pCounter;
C* _ptr;
template < class Other > friend class SharedPtr;
template<class Other> friend class SharedPtr;
};

View File

@@ -1,7 +1,7 @@
//
// SimpleHashTable.h
//
// $Id: //poco/1.2/Foundation/include/Poco/SimpleHashTable.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/SimpleHashTable.h#2 $
//
// Library: Foundation
// Package: Core
@@ -191,7 +191,7 @@ public:
UInt32 origHash = hsh;
while (_entries[hsh % _maxCapacity])
{
if(_entries[hsh % _maxCapacity]->key == key)
if (_entries[hsh % _maxCapacity]->key == key)
{
_entries[hsh % _maxCapacity]->value = value;
return;
@@ -225,7 +225,7 @@ public:
{
if (_entries[hsh % _maxCapacity])
{
if(_entries[hsh % _maxCapacity]->key == key)
if (_entries[hsh % _maxCapacity]->key == key)
{
return _entries[hsh % _maxCapacity]->value;
}
@@ -248,7 +248,7 @@ public:
{
if (_entries[hsh % _maxCapacity])
{
if(_entries[hsh % _maxCapacity]->key == key)
if (_entries[hsh % _maxCapacity]->key == key)
{
return _entries[hsh % _maxCapacity]->key;
}
@@ -277,7 +277,7 @@ public:
{
if (_entries[hsh % _maxCapacity])
{
if(_entries[hsh % _maxCapacity]->key == key)
if (_entries[hsh % _maxCapacity]->key == key)
{
v = _entries[hsh % _maxCapacity]->value;
return true;
@@ -304,7 +304,7 @@ public:
{
if (_entries[hsh % _maxCapacity])
{
if(_entries[hsh % _maxCapacity]->key == key)
if (_entries[hsh % _maxCapacity]->key == key)
{
return true;
}

View File

@@ -1,7 +1,7 @@
//
// StrategyCollection.h
//
// $Id: //poco/1.2/Foundation/include/Poco/StrategyCollection.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/StrategyCollection.h#2 $
//
// Library: Foundation
// Package: Cache
@@ -60,14 +60,14 @@ public:
typedef typename Strategies::const_iterator ConstIterator;
public:
StrategyCollection()
StrategyCollection()
{
}
virtual ~StrategyCollection()
{
~StrategyCollection()
{
}
void pushBack(AbstractStrategy<TKey, TValue>* pStrat)
/// Adds an AbstractStrategy to the collection. Class takes ownership of pointer
{
@@ -78,7 +78,7 @@ public:
/// Removes the last added AbstractStrategy from the collection.
{
_strategies.pop_back();
}
}
void onAdd(const void* pSender, const KeyValueArgs <TKey, TValue>& key)
/// Adds the key to the strategy.
@@ -103,7 +103,7 @@ public:
(*it)->onRemove(pSender, key);
}
}
void onGet(const void* pSender, const TKey& key)
{
Iterator it = _strategies.begin();
@@ -113,7 +113,7 @@ public:
(*it)->onGet(pSender, key);
}
}
void onClear(const void* pSender, const EventArgs& args)
{
Iterator it = _strategies.begin();
@@ -128,7 +128,7 @@ public:
{
Iterator it = _strategies.begin();
Iterator endIt = _strategies.end();
for (; it != endIt && key.isValid (); ++it)
for (; it != endIt && key.isValid(); ++it)
{
(*it)->onIsValid(pSender, key);
}

View File

@@ -1,7 +1,7 @@
//
// Timestamp.h
//
// $Id: //poco/1.2/Foundation/include/Poco/Timestamp.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/Timestamp.h#2 $
//
// Library: Foundation
// Package: DateTime
@@ -80,6 +80,7 @@ public:
/// Swaps the Timestamp with another one.
void update();
/// Updates the Timestamp with the current time.
bool operator == (const Timestamp& ts) const;
bool operator != (const Timestamp& ts) const;

View File

@@ -1,7 +1,7 @@
//
// ValidArgs.h
//
// $Id: //poco/1.2/Foundation/include/Poco/ValidArgs.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/ValidArgs.h#2 $
//
// Library: Foundation
// Package: Cache
@@ -46,7 +46,7 @@
namespace Poco {
template <class TKey>
template <class TKey>
class ValidArgs
{
public:
@@ -82,7 +82,7 @@ public:
}
protected:
const TKey& _key;
const TKey& _key;
bool _isValid;
private: