CCCC - C and C++ Code Counter  9999-git
CCCC Development version (post-3.1.4)
Public Member Functions | Private Types | Private Attributes | List of all members
CCCC_Table< T > Class Template Reference

#include <cccc_tbl.h>

Inheritance diagram for CCCC_Table< T >:
[legend]
Collaboration diagram for CCCC_Table< T >:
[legend]

Public Member Functions

 CCCC_Table ()
 
virtual ~CCCC_Table ()
 
int records ()
 
T * find (string name)
 
T * find_or_insert (T *new_item_ptr)
 
bool remove (T *old_item_ptr)
 
void reset_iterator ()
 
T * first_item ()
 
T * next_item ()
 
virtual int get_count (const char *count_tag)
 
void sort ()
 

Private Types

typedef std::map< string, T * > map_t
 

Private Attributes

map_t::iterator iter_
 
bool sorted
 

Detailed Description

template<class T>
class CCCC_Table< T >

Definition at line 37 of file cccc_tbl.h.

Member Typedef Documentation

template<class T>
typedef std::map<string,T*> CCCC_Table< T >::map_t
private

Definition at line 40 of file cccc_tbl.h.

Constructor & Destructor Documentation

template<class T >
CCCC_Table< T >::CCCC_Table ( )

Definition at line 30 of file cccc_tbl.cc.

31 : sorted(true)
32 {
33  iter_ = map_t::end();
34 }
bool sorted
Definition: cccc_tbl.h:42
map_t::iterator iter_
Definition: cccc_tbl.h:41
template<class T >
CCCC_Table< T >::~CCCC_Table ( )
virtual

Definition at line 36 of file cccc_tbl.cc.

37 {
38  // the container should manage the destruction of its own
39  // nodes correctly, we just need to get rid of the
40  // objects to which we hold pointers.
41  // NB Although CCCC_Table holds pointers, it owns the
42  // objects they point to and is responsible for their disposal.
43  T* itemptr=first_item();
44  while(itemptr!=NULL)
45  {
46  delete itemptr;
47  itemptr=next_item();
48  }
49 }
T * first_item()
Definition: cccc_tbl.cc:118
T * next_item()
Definition: cccc_tbl.cc:124

Member Function Documentation

template<class T >
T * CCCC_Table< T >::find ( string  name)

Definition at line 66 of file cccc_tbl.cc.

67 {
68  T *retval=NULL;
69  typename map_t::iterator value_iterator=map_t::find(name);
70  if(value_iterator!=map_t::end())
71  {
72  retval=(*value_iterator).second;
73  }
74  return retval;
75 }

Here is the caller graph for this function:

template<class T>
T * CCCC_Table< T >::find_or_insert ( T *  new_item_ptr)

Definition at line 78 of file cccc_tbl.cc.

79 {
80  string new_key=new_item_ptr->key();
81  T *retval=find(new_key);
82  if(retval==NULL)
83  {
84  typename map_t::value_type new_pair(new_key,new_item_ptr);
85  map_t::insert(new_pair);
86  sorted=false;
87  retval=new_item_ptr;
88  }
89  return retval;
90 }
bool sorted
Definition: cccc_tbl.h:42
T * find(string name)
Definition: cccc_tbl.cc:66

Here is the caller graph for this function:

template<class T >
T * CCCC_Table< T >::first_item ( )

Definition at line 118 of file cccc_tbl.cc.

119 {
120  reset_iterator();
121  return next_item();
122 }
void reset_iterator()
Definition: cccc_tbl.cc:113
T * next_item()
Definition: cccc_tbl.cc:124

Here is the caller graph for this function:

template<class T >
int CCCC_Table< T >::get_count ( const char *  count_tag)
virtual

Definition at line 52 of file cccc_tbl.cc.

53 {
54  int retval=0;
55  T* itemptr=first_item();
56  while(itemptr!=NULL)
57  {
58  retval+=itemptr->get_count(count_tag);
59  itemptr=next_item();
60  }
61 
62  return retval;
63 }
T * first_item()
Definition: cccc_tbl.cc:118
T * next_item()
Definition: cccc_tbl.cc:124

Here is the caller graph for this function:

template<class T >
T * CCCC_Table< T >::next_item ( )

Definition at line 124 of file cccc_tbl.cc.

125 {
126  T* retval=NULL;
127  if(iter_!=map_t::end())
128  {
129  retval=(*iter_).second;
130  iter_++;
131  }
132  return retval;
133 }
map_t::iterator iter_
Definition: cccc_tbl.h:41

Here is the caller graph for this function:

template<class T >
int CCCC_Table< T >::records ( )

Definition at line 135 of file cccc_tbl.cc.

136 {
137  return map_t::size();
138 }

Here is the caller graph for this function:

template<class T>
bool CCCC_Table< T >::remove ( T *  old_item_ptr)

Definition at line 93 of file cccc_tbl.cc.

94 {
95  bool retval=false;
96  typename map_t::iterator value_iterator=map_t::find(old_item_ptr->key());
97  if(value_iterator!=map_t::end())
98  {
99  this->erase(value_iterator);
100  retval=true;
101  }
102  return retval;
103 }

Here is the caller graph for this function:

template<class T >
void CCCC_Table< T >::reset_iterator ( )

Definition at line 113 of file cccc_tbl.cc.

114 {
115  iter_=map_t::begin();
116 }
map_t::iterator iter_
Definition: cccc_tbl.h:41
template<class T >
void CCCC_Table< T >::sort ( )

Definition at line 105 of file cccc_tbl.cc.

106 {
107  if(sorted==false)
108  {
109  sorted=true;
110  }
111 }
bool sorted
Definition: cccc_tbl.h:42

Here is the caller graph for this function:

Member Data Documentation

template<class T>
map_t::iterator CCCC_Table< T >::iter_
private

Definition at line 41 of file cccc_tbl.h.

template<class T>
bool CCCC_Table< T >::sorted
private

Definition at line 42 of file cccc_tbl.h.


The documentation for this class was generated from the following files: