31 #ifndef __ROCCOM_MAPS_H__
32 #define __ROCCOM_MAPS_H__
42 template <
class Object>
44 typedef std::vector<Object>
I2O;
45 typedef std::map<std::string, int>
N2I;
58 bool is_const=false) throw(COM_exception);
62 {
return names[
i].find(
" (const)")!=std::string::npos; }
80 std::pair<int,Object *>
find(
const std::string &
name,
bool is_const=
false) {
81 N2I::iterator it=
n2i.find( is_const?name+
"(const)":name);
83 return std::pair<int,Object *>(-1,NULL);
85 return std::pair<int,Object *>(it->second, &
i2o[ it->second]);
96 template <
class Object>
100 if (is_const) name.append(
" (const)");
102 N2I::iterator it = n2i.find(name);
103 int i = ( it == n2i.end()) ? -1 : it->second;
107 else if ( salvaged.empty()) {
108 i=i2o.size(); n2i[name] =
i;
109 i2o.push_back( t); names.push_back( name);
112 i=salvaged.front(); salvaged.pop_front();
113 n2i[name] =
i; i2o[
i] = t; names[
i] = name;
118 template <
class Object>
121 if (is_const) name.append(
" (const)");
123 N2I::iterator it = n2i.find(name);
125 salvaged.push_back( it->second);
140 if ( i+1>
verbs.size()) {
141 verbs.resize(i+1,
false);
150 using Base::operator[];
A Function object corresponds to a function member of a window.
N2I n2i
Mapping from names to indices.
int add_object(const std::string &n, Function *t)
Insert a function into the table.
std::vector< std::string > get_names()
std::pair< int, Object * > find(const std::string &name, bool is_const=false)
std::vector< char > verbs
Whether verbose is on.
const std::string & name(int i) const
Name of the object.
std::map< std::string, int > N2I
Mapping from names to indices.
This file contains some definitions of macros and constants for Roccoms.
Encapsulates the states of an exception.
I2O i2o
Mapping from index to objects.
std::vector< double > wtimes_tree
Accumulator of wall-clock time spent by itself and those functions called by it.
std::vector< double > wtimes_self
Accumulator of wall-clock time spent by itself excluding functions called by it.
void remove_object(std::string name, bool is_const=false)
Remove an object from the table.
const Object & operator[](int i) const
Access an object using its handle.
std::vector< std::string > names
Name of the objects.
std::vector< int > counts
Counts of the number of calls.
Roccom_map< Function * > Base
bool is_immutable(int i) const
whether the object mutable
Supports mapping from names to handles and vice-versa for a module, window, function, or attribute.
int add_object(std::string name, Object t, bool is_const=false)
Insert an object into the table.
Object & operator[](int i)
std::list< int > salvaged
List of salvaged indices.
std::vector< Object > I2O
Mapping from indices to objects.