/usr/include/tjutils/tjvallist.h is in libodin-dev 1.8.8-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 | /***************************************************************************
tjvallist.h - description
-------------------
begin : Wed Apr 14 2004
copyright : (C) 2000-2014 by Thies H. Jochimsen
email : thies@jochimsen.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 TJVALLIST_H
#define TJVALLIST_H
#include <tjutils/tjvector.h>
#include <tjutils/tjlabel.h>
/**
* @addtogroup tjutils
* @{
*/
/**
* This class holds nested lists (tree) of values.
* Each node can contain a single value, or a list of other nested lists.
* In addition, it contains a repetition counter for this node.
* Its main purpose is to retrieve value lists (e.g. frequency lists, delay lists, reco indices) from the sequence tree.
*/
template <class T>
class ValList : public virtual Labeled {
/**
* Actual data with reference counting
*/
struct ValListData {
ValListData() : val(0), times(1), sublists(0), elements_size_cache(0), references(0) {}
ValListData(const ValListData& vld) : times(vld.times), elements_size_cache(vld.elements_size_cache), references(0) {
if(vld.val) val=new T(*vld.val);
else val=0;
if(vld.sublists) sublists=new STD_list< ValList<T> >(*vld.sublists);
else sublists=0;
}
~ValListData() {
if(sublists) delete sublists;
if(val) delete val;
}
T* val; // zero pointer indicates 'value not set'
unsigned int times;
STD_list< ValList<T> >* sublists; // zero pointer indicates 'list not set'
unsigned int elements_size_cache; // cache for the number of values of one repetition of this node
unsigned short references; // reference counter
};
public:
/**
* Empty node with given label and repetitions
*/
ValList(const STD_string& object_label="unnamedValList", unsigned int repetitions=1);
/**
* Node with a single value
*/
ValList(T value);
/**
* Copy constructor
*/
ValList(const ValList<T>& vl);
~ValList();
/**
* Assignment operator
*/
ValList& operator = (const ValList<T>& vl);
/**
* Make node single value
*/
ValList& set_value(T value);
/**
* Append another node to this
*/
ValList& add_sublist(const ValList<T>& vl);
/**
* Multiply number of repetitions of this node by 'reptimes'
*/
ValList& multiply_repetitions(unsigned int reptimes) {copy_on_write(); data->times*=reptimes; return *this;}
/**
* Returns unrolled values of nested list
*/
STD_vector<T> get_values_flat() const;
/**
* Returns unrolled values of nested list for one repetition of this list
*/
STD_vector<T> get_elements_flat() const;
/**
* Equal operator
*/
bool operator == (const ValList<T>& vl) const;
/**
* Comparison operator
*/
bool operator < (const ValList<T>& vl) const;
/**
* Acess i'th value in the nested list
*/
T operator [] (unsigned int i) const;
/**
* Returns number of values of one repetition of this node
*/
// unsigned int elements_size() const;
/**
* Returns number of values
*/
unsigned int size() const {return data->times*data->elements_size_cache;}
/**
* Serializes list to a string
*/
STD_string printvallist() const;
/**
* Parses list from string
*/
bool parsevallist(const STD_string& str);
/**
* Prints value list to stream
*/
STD_ostream& print2stream(STD_ostream& os) const;
/**
* Clears the value list
*/
void clear();
private:
friend class ValListTest;
bool equalelements (const ValList<T>& vl) const;
ValList& increment_repetitions(unsigned int reptimes) {copy_on_write(); data->times+=reptimes; return *this;}
unsigned int get_repetitions() const {return data->times;}
void flatten_sublists();
void copy_on_write();
ValListData* data;
};
///////////////////////////////////////////////////
/** @}
*/
#endif
|