/usr/include/tjutils/tjlist.h is in libodin-dev 1.8.5-2ubuntu1.
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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | /***************************************************************************
tjlist.h - description
-------------------
begin : Mon Aug 5 2002
copyright : (C) 2001 by Thies H. Jochimsen
email : jochimse@cns.mpg.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef TJLIST_H
#define TJLIST_H
#include <tjutils/tjutils.h>
/**
* @addtogroup tjutils
* @{
*/
// for debugging List
class ListComponent {
public:
static const char* get_compName();
};
//////////////////////////////////////////////////////////////
class ListItemBase {};
class ListBase {
public:
virtual ~ListBase() {}
virtual void objlist_remove(ListItemBase* item) = 0;
};
//////////////////////////////////////////////////////////////
template<class I>
class ListItem : public ListItemBase {
public:
ListItem() {}
~ListItem();
// empty copy and assignment operator to avoid copying of 'objhandlers' member
ListItem(const ListItem&) {}
ListItem& operator = (const ListItem&) {return *this;}
unsigned int numof_references() const {return objhandlers.size();}
const ListItemBase& append_objhandler(ListBase& objhandler) const;
const ListItemBase& remove_objhandler(ListBase& objhandler) const;
private:
mutable STD_list<ListBase*> objhandlers;
};
/////////////////////////////////////////////
/**
* This template class handles a list of references to other objects.
* In contrast to the STL list, it stores only pointers to the members
* of the list instead of storing copies. That means, if a member of the
* list is modified, the property of the whole list changes. This list
* is well suited to build blocks of objects that will be modified after
* they have been inserted into the list, e.g. a list of parameters.
*
* If you want to use this list, i.e. create an instantiation for a specific
* data type T, you must first decide whether to use const objects, i.e. which
* will not changed via the list, or non-const objects that can be modified
* via the list. In the former case, create a list by instatiating
*
* List<T,const T*,const T&>
*
* otherwise
*
* List<T,T*,T&>
*
* Classes which are to be inserted into the list must be derived
* from the base class
*
* ListItem<T>
*
* This construct ensures that whenever an item of the list is deleted,
* it deregisters itself from the list.
*/
template<class I,class P,class R> class List : public ListBase {
public:
/**
* Constructs an empty List
*/
List();
/**
* Destructor
*/
~List();
/**
* Assignment operator that will result in a list that holds references to all objects for which
* 'l' contains a reference
*/
List& operator = (const List& l);
/**
* Removes all items from the list
*/
List& clear();
/**
* Appends a reference to 'item'
*/
List& append(R item);
/**
* Removes all references to 'item'
*/
List& remove(R item);
/**
* Returns the number of items in the list
*/
unsigned int size() const {return objlist.size();}
/**
* Iterator for mutable lists
*/
typedef typename STD_list<P>::iterator iter;
/**
* Iterator for const lists
*/
typedef typename STD_list<P>::const_iterator constiter;
/**
* returns an iterator that points to the head of the list (for mutable lists)
*/
iter get_begin() {return objlist.begin();}
/**
* returns an iterator that points to the end of the list (for mutable lists)
*/
iter get_end() {return objlist.end();}
/**
* returns an iterator that points to the head of the list (for const lists)
*/
constiter get_const_begin() const {return objlist.begin();}
/**
* returns an iterator that points to the end of the list (for const lists)
*/
constiter get_const_end() const {return objlist.end();}
private:
void objlist_remove(ListItemBase* item);
void link_item(P ptr);
void unlink_item(P ptr);
STD_list<P> objlist;
};
/** @}
*/
#endif
|