Loading...
Searching...
No Matches
Repository.h
Go to the documentation of this file.
// -*- c++ -*-
//------------------------------------------------------------------------------
// Repository.h
//------------------------------------------------------------------------------
// Copyright (c) 2003 by Vladislav Grinchenko
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//------------------------------------------------------------------------------
// Date: May 7, 2003
//------------------------------------------------------------------------------
#ifndef REPOSITORY_H
#define REPOSITORY_H
#include <vector>
using std::vector;
namespace ASSA {
template<typename T>
class Repository
{
public:
typedef T* value_type;
typedef size_t size_type;
typedef typename std::vector<value_type> list_t;
typedef typename std::vector<value_type>::iterator iterator;
typedef typename std::vector<value_type>::const_iterator const_iterator;
Repository () {
m_collection = new list_t;
}
virtual ~Repository () {
if (m_collection) { clear (); delete m_collection; }
}
iterator begin () { return m_collection->begin (); }
const_iterator begin () const { return m_collection->begin (); }
iterator end () { return m_collection->end (); }
const_iterator end () const { return m_collection->end (); }
bool empty () const { return m_collection->empty (); }
size_type size () const { return m_collection->size (); }
void push_back (const value_type& x_) { m_collection->push_back (x_); }
void erase (iterator position_) { m_collection->erase (position_); }
bool erase (const value_type& x_) {
iterator it = begin ();
while (it != end ()) {
if ((*it) == x_) { erase (it); break; }
it++;
}
}
void clear () {
m_collection->erase (m_collection->begin (), m_collection->end ());
}
private:
list_t* m_collection;
};
} // @end namespace ASSA
#endif /* REPOSITORY_H */
ASSA::Repository::const_iterator
std::vector< value_type >::const_iterator const_iterator
Definition Repository.h:41
ASSA::Repository::begin
iterator begin()
Get iterator to the first element of the repository.
Definition Repository.h:55
ASSA::Repository::m_collection
list_t * m_collection
Definition Repository.h:95
ASSA::Repository::size_type
size_t size_type
Definition Repository.h:37
ASSA::Repository::erase
bool erase(const value_type &x_)
Remove element.
Definition Repository.h:81
ASSA::Repository::clear
void clear()
Empty repository.
Definition Repository.h:90
ASSA::Repository::list_t
std::vector< value_type > list_t
Definition Repository.h:39
ASSA::Repository::erase
void erase(iterator position_)
Remove element at the position_ iterator.
Definition Repository.h:76
ASSA::Repository::~Repository
virtual ~Repository()
Destructor.
Definition Repository.h:50
ASSA::Repository::size
size_type size() const
Return number of elements in the repository.
Definition Repository.h:70
ASSA::Repository::empty
bool empty() const
Return true if repository is empty.
Definition Repository.h:67
ASSA::Repository::iterator
std::vector< value_type >::iterator iterator
Definition Repository.h:40
ASSA::Repository::begin
const_iterator begin() const
Get constant iterator to the first element of the repository.
Definition Repository.h:58
ASSA::Repository::push_back
void push_back(const value_type &x_)
Add new element to the repository.
Definition Repository.h:73
ASSA::Repository::end
iterator end()
Get iterator to the end of the repository.
Definition Repository.h:61
ASSA::Repository::value_type
T * value_type
Definition Repository.h:36
ASSA::Repository::end
const_iterator end() const
Get constant iterator to the end of the repository.
Definition Repository.h:64
ASSA::Repository::Repository
Repository()
Constructor.
Definition Repository.h:45
ASSA
Definition Acceptor.h:40