fixed: UGContainer<Type> used a std::vector<Type> and when a new item was inserted

then current iterators (and pointers) were invalidated
         now we are using std::vector<Type*>
         this caused some crashes when a new user was added by 'adduser' winix function
added:   plugin 'export' is able to upload files on a remote server now
         (not finished yet)
changed: Thumb class is now called: Image
         and we are able to resize images too
         (some new options in the config and in mount points)
added:   some new plugin messages



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@764 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2011-09-13 06:08:34 +00:00
parent 72be443414
commit 39923d6617
58 changed files with 2258 additions and 654 deletions

View File

@@ -11,6 +11,7 @@
#define headerfile_winix_core_ugcontainer
#include <vector>
#include <list>
#include <map>
#include <stdexcept>
@@ -21,11 +22,16 @@
template<class Type>
class UGContainer
{
public:
typedef typename std::vector<Type> Table;
typedef typename Table::iterator Iterator;
typedef typename Table::size_type SizeType;
~UGContainer();
// we have to use a pointer (Type*) here
// because we are remembering some pointers to the items elsewhere
// so the pointers should not be invalidated
typedef typename std::vector<Type*> Table;
typedef typename Table::iterator Iterator;
typedef typename Table::size_type SizeType;
typedef typename std::map<long, SizeType> TableId;
typedef typename std::map<std::wstring, SizeType> TableName;
@@ -65,7 +71,14 @@ private:
template<class Type>
UGContainer<Type>::UGContainer() // : table(100)
UGContainer<Type>::~UGContainer()
{
Clear();
}
template<class Type>
UGContainer<Type>::UGContainer()
{
}
@@ -108,7 +121,7 @@ typename UGContainer<Type>::Iterator UGContainer<Type>::PushBack(const Type & ty
if( Is(type.id) || Is(type.name) )
return End();
table.push_back(type);
table.push_back(new Type(type));
log << log2 << "UGCont: added, id: " << type.id << ", name: " << type.name << logend;
AddIndexes( table.size() - 1 );
@@ -121,6 +134,9 @@ return --table.end();
template<class Type>
void UGContainer<Type>::Clear()
{
for(size_t i=0 ; i<table.size() ; ++i)
delete table[i];
table.clear();
table_id.clear();
table_name.clear();
@@ -182,10 +198,10 @@ return table.begin() + i->second;
template<class Type>
void UGContainer<Type>::AddIndexes(UGContainer<Type>::SizeType pos)
{
table_id.insert( std::make_pair(table[pos].id, pos) );
table_name.insert( std::make_pair(table[pos].name, pos) );
table_id.insert( std::make_pair(table[pos]->id, pos) );
table_name.insert( std::make_pair(table[pos]->name, pos) );
log << log4 << "UGCont: added indexes to: id: " << table[pos].id << ", name: " << table[pos].name << logend;
log << log4 << "UGCont: added indexes to: id: " << table[pos]->id << ", name: " << table[pos]->name << logend;
}
@@ -216,7 +232,7 @@ Type & UGContainer<Type>::operator[](UGContainer<Type>::SizeType pos)
if( pos >= table.size() )
throw std::out_of_range("UGContainer: operator[]: index is out of range");
return table[pos];
return *table[pos];
}