/usr/include/assa-3.5/assa/Repository.h is in libassa-3.5-5-dev 3.5.1-6build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | // -*- 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 {
/** @file Repository.h
Repository class is a template class to hold a collection of
similar objects. It is typically used to hold references dynamically
created ServiceHandlers. Repository doesn't manage references it holds.
It is only used for the purposes of sending a signal to all elements
of the Repository collectively.
*/
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;
/** Constructor
*/
Repository () {
m_collection = new list_t;
}
/// Destructor
virtual ~Repository () {
if (m_collection) { clear (); delete m_collection; }
}
/// Get iterator to the first element of the repository
iterator begin () { return m_collection->begin (); }
/// Get constant iterator to the first element of the repository
const_iterator begin () const { return m_collection->begin (); }
/// Get iterator to the end of the repository
iterator end () { return m_collection->end (); }
/// Get constant iterator to the end of the repository
const_iterator end () const { return m_collection->end (); }
/// Return true if repository is empty
bool empty () const { return m_collection->empty (); }
/// Return number of elements in the repository
size_type size () const { return m_collection->size (); }
/// Add new element to the repository
void push_back (const value_type& x_) { m_collection->push_back (x_); }
/// Remove element at the position_ iterator
void erase (iterator position_) { m_collection->erase (position_); }
/** Remove element
@return true if element was found and erased; false otherwise
*/
bool erase (const value_type& x_) {
iterator it = begin ();
while (it != end ()) {
if ((*it) == x_) { erase (it); break; }
it++;
}
}
/// Empty repository
void clear () {
m_collection->erase (m_collection->begin (), m_collection->end ());
}
private:
list_t* m_collection;
};
} // @end namespace ASSA
#endif /* REPOSITORY_H */
|