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

#include <cccc_mod.h>

Inheritance diagram for CCCC_Module:
[legend]
Collaboration diagram for CCCC_Module:
[legend]

Public Member Functions

string name (int name_level) const
 
int FromFile (ifstream &infile)
 
int ToFile (ofstream &outfile)
 
virtual int get_count (const char *count_tag)
 
int is_trivial ()
 
- Public Member Functions inherited from CCCC_Record
virtual ~CCCC_Record ()
 
virtual string key () const
 
AugmentedBool get_flag (PSFlag psf)
 
virtual void add_extent (CCCC_Item &)
 
virtual void sort ()
 

Private Types

typedef std::map< string, CCCC_Member * > member_map_t
 
typedef std::map< string, CCCC_UseRelationship * > relationship_map_t
 

Private Member Functions

 CCCC_Module ()
 

Private Attributes

CCCC_Projectproject
 
string module_name
 
string module_type
 
member_map_t member_map
 
relationship_map_t client_map
 
relationship_map_t supplier_map
 

Friends

class CCCC_Project
 
class CCCC_Html_Stream
 
class CCCC_Xml_Stream
 

Additional Inherited Members

- Static Public Member Functions inherited from CCCC_Record
static CCCC_Projectget_active_project ()
 
static void set_active_project (CCCC_Project *prj)
 
- Protected Types inherited from CCCC_Record
typedef CCCC_Table< CCCC_ExtentExtent_Table
 
- Protected Member Functions inherited from CCCC_Record
virtual void merge_flags (string &new_flags)
 
- Protected Attributes inherited from CCCC_Record
Extent_Table extent_table
 
string flags
 

Detailed Description

Definition at line 42 of file cccc_mod.h.

Member Typedef Documentation

typedef std::map<string,CCCC_Member*> CCCC_Module::member_map_t
private

Definition at line 50 of file cccc_mod.h.

typedef std::map<string,CCCC_UseRelationship*> CCCC_Module::relationship_map_t
private

Definition at line 53 of file cccc_mod.h.

Constructor & Destructor Documentation

CCCC_Module::CCCC_Module ( )
private

Definition at line 29 of file cccc_mod.cc.

30 {
32 }
static CCCC_Project * get_active_project()
Definition: cccc_rec.cc:28
CCCC_Project * project
Definition: cccc_mod.h:47

Here is the call graph for this function:

Member Function Documentation

int CCCC_Module::FromFile ( ifstream &  infile)

Definition at line 228 of file cccc_mod.cc.

229 {
230  int retval=RECORD_ERROR;
231 
232  CCCC_Item next_line;
233  next_line.FromFile(ifstr);
234  ifstr_line++;
235 
236  string line_keyword_dummy;
237 
238  CCCC_Module *found_mptr=NULL;
239 
240  if(
241  next_line.Extract(line_keyword_dummy) &&
242  next_line.Extract(this->module_name) &&
243  next_line.Extract(this->module_type)
244  )
245  {
246  found_mptr=
248  if(found_mptr==this)
249  {
250  // the newly created instance of the module is the first
251  // and has taken its place in the database, so we protect
252  // it from deletion
253  retval=RECORD_ADDED;
254  }
255  else
256  {
257  retval=RECORD_TRANSCRIBED;
258  }
259 
260  // process extent records
261  while(PeekAtNextLinePrefix(ifstr,MODEXT_PREFIX))
262  {
263  CCCC_Extent *new_extent=new CCCC_Extent;
264  next_line.FromFile(ifstr);
265  ifstr_line++;
266  string module_name_dummy, module_type_dummy;
267 
268  if(
269  next_line.Extract(line_keyword_dummy) &&
270  next_line.Extract(module_name_dummy) &&
271  next_line.Extract(module_type_dummy) &&
272  new_extent->GetFromItem(next_line)
273  )
274  {
275  // We don't ever expect to find duplicated extent records
276  // but just in case...
277  CCCC_Extent *found_eptr=
278  found_mptr->extent_table.find_or_insert(new_extent);
279  if(found_eptr!=new_extent)
280  {
281  cerr << "Failed to add extent for module "
282  << found_mptr->key() << " at line " << ifstr_line
283  << endl;
284  delete new_extent;
285  }
286  }
287  }
288  }
289  else
290  {
291  // unexpected problem with the input
292  retval=RECORD_ERROR;
293  }
294 
295  // If the import was successful, we will also have imported all dependent
296  // extent records following the main record.
297  // If not, we must skip them.
298  while(PeekAtNextLinePrefix(ifstr,MODEXT_PREFIX))
299  {
300  CCCC_Item next_line;
301  next_line.FromFile(ifstr);
302  ifstr_line++;
303  cerr << "Ignoring member extent on line " << ifstr_line << endl;
304  }
305 
306  return retval;
307 }
CCCC_Table< CCCC_Module > module_table
Definition: cccc_prj.h:54
virtual string key() const
Definition: cccc_rec.cc:76
int ifstr_line
Definition: cccc_db.cc:32
string module_name
Definition: cccc_mod.h:48
bool Extract(string &s)
Definition: cccc_itm.cc:47
string module_type
Definition: cccc_mod.h:48
CCCC_Project * current_loading_project
Definition: cccc_db.cc:25
int GetFromItem(CCCC_Item &item)
Definition: cccc_ext.cc:84
T * find_or_insert(T *new_item_ptr)
Definition: cccc_tbl.cc:78
bool FromFile(ifstream &ifstr)
Definition: cccc_itm.cc:119
Extent_Table extent_table
Definition: cccc_rec.h:45
static const string MODEXT_PREFIX
Definition: cccc_mod.h:36
bool PeekAtNextLinePrefix(ifstream &ifstr, string pfx)
Definition: cccc_db.cc:51

Here is the call graph for this function:

Here is the caller graph for this function:

int CCCC_Module::get_count ( const char *  count_tag)
virtual

Implements CCCC_Record.

Definition at line 64 of file cccc_mod.cc.

65 {
66  int retval=0;
67  if(strcmp(count_tag,"NOM")==0)
68  {
69  if(is_trivial()==FALSE)
70  {
71  retval=1;
72  }
73  }
74  else if(strcmp(count_tag,"CBO")==0)
75  {
76  retval=client_map.size()+supplier_map.size();
77  }
78  else if(strcmp(count_tag,"NOC")==0)
79  {
80  retval=0;
81 
82  relationship_map_t::iterator iter;
83  iter=client_map.begin();
84  while(iter!=client_map.end())
85  {
86  if((*iter).second->get_usetype()==utINHERITS)
87  {
88  retval++;
89  }
90  iter++;
91  }
92  }
93  else if(strcmp(count_tag,"DIT")==0)
94  {
95  retval=0;
96 
97  // cyclical inheritance relationships in code would
98  // never compile, but this is no excuse for us allowing them
99  // to cause us to overflow the stack
100  static int recursion_depth=0;
101  recursion_depth++;
102  if(recursion_depth>100)
103  {
104  cerr << "Recursion overflow attempting to calculate DIT for "
105  << key() << endl;
106  retval=1000;
107  }
108  else
109  {
110  relationship_map_t::iterator iter;
111  iter=supplier_map.begin();
112  while(iter!=supplier_map.end())
113  {
114  if((*iter).second->get_usetype()==utINHERITS)
115  {
116  int parent_depth=
117  (*iter).second->supplier_module_ptr(project)->get_count("DIT");
118  if(retval<parent_depth+1)
119  {
120  retval=parent_depth+1;
121  }
122  }
123  iter++;
124  }
125  }
126  recursion_depth--;
127  }
128  else if(strncmp(count_tag,"FI",2)==0)
129  {
130  relationship_map_t::iterator iter;
131  iter=supplier_map.begin();
132  while(iter!=supplier_map.end())
133  {
134  retval+=(*iter).second->get_count(count_tag);
135  iter++;
136  }
137  }
138  else if(strncmp(count_tag,"FO",2)==0)
139  {
140  relationship_map_t::iterator iter;
141  iter=client_map.begin();
142  while(iter!=client_map.end())
143  {
144  retval+=(*iter).second->get_count(count_tag);
145  iter++;
146  }
147  }
148  else if(strncmp(count_tag,"IF4",3)==0)
149  {
150  char if4_suffix=count_tag[3];
151  string fi_variant="FI", fo_variant="FO";
152  if(if4_suffix!=0)
153  {
154  fi_variant+=if4_suffix;
155  fo_variant+=if4_suffix;
156  }
157  retval=get_count(fi_variant.c_str())*get_count(fo_variant.c_str());
158  retval*=retval;
159  }
160  else
161  {
163  while(extPtr!=NULL)
164  {
165  int extent_count=extPtr->get_count(count_tag);
166  retval+=extent_count;
167  extPtr=extent_table.next_item();
168  }
169 
170  member_map_t::iterator memIter=member_map.begin();
171  while(memIter!=member_map.end())
172  {
173  int member_count=(*memIter).second->get_count(count_tag);
174  retval+=member_count;
175  memIter++;
176  }
177  }
178  return retval;
179 }
virtual string key() const
Definition: cccc_rec.cc:76
relationship_map_t client_map
Definition: cccc_mod.h:54
int is_trivial()
Definition: cccc_mod.cc:181
virtual int get_count(const char *count_tag)
Definition: cccc_mod.cc:64
int get_count(const char *count_tag)
Definition: cccc_ext.cc:147
T * first_item()
Definition: cccc_tbl.cc:118
T * next_item()
Definition: cccc_tbl.cc:124
Extent_Table extent_table
Definition: cccc_rec.h:45
relationship_map_t supplier_map
Definition: cccc_mod.h:55
member_map_t member_map
Definition: cccc_mod.h:51
CCCC_Project * project
Definition: cccc_mod.h:47

Here is the call graph for this function:

Here is the caller graph for this function:

int CCCC_Module::is_trivial ( )

Definition at line 181 of file cccc_mod.cc.

182 {
183  int retval=FALSE;
184 
185  if(
186  (module_type=="builtin") ||
187  (module_type=="enum") ||
188  (module_type=="struct") ||
189  (module_type=="trivial")
190  )
191  {
192  retval=TRUE;
193  }
194 
195  return retval;
196 }
string module_type
Definition: cccc_mod.h:48

Here is the caller graph for this function:

string CCCC_Module::name ( int  name_level) const
virtual

Reimplemented from CCCC_Record.

Definition at line 35 of file cccc_mod.cc.

36 {
37  string retval;
38 
39  switch(name_level)
40  {
41  case nlMODULE_TYPE:
42  retval=module_type;
43  break;
44 
45  case nlMODULE_NAME:
46  retval=module_name;
47  break;
48 
50  retval=module_type;
51  if(retval.size()>0)
52  {
53  retval=retval+" ";
54  }
55  retval=retval+module_name;
56  break;
57 
58  default:
59  retval=module_name;
60  }
61  return retval.c_str();
62 }
string module_name
Definition: cccc_mod.h:48
string module_type
Definition: cccc_mod.h:48

Here is the caller graph for this function:

int CCCC_Module::ToFile ( ofstream &  outfile)

Definition at line 198 of file cccc_mod.cc.

199 {
200  int retval=FALSE;
201  CCCC_Item module_line;
202  module_line.Insert(MODULE_PREFIX);
203  module_line.Insert(module_name);
204  module_line.Insert(module_type);
205  module_line.ToFile(ofstr);
206 
207  CCCC_Extent *extent_ptr=extent_table.first_item();
208  while(extent_ptr!=NULL)
209  {
210  CCCC_Item extent_line;
211  extent_line.Insert(MODEXT_PREFIX);
212  extent_line.Insert(module_name);
213  extent_line.Insert(module_type);
214  extent_ptr->AddToItem(extent_line);
215  extent_line.ToFile(ofstr);
216 
217  extent_ptr=extent_table.next_item();
218  }
219 
220  if(ofstr.good())
221  {
222  retval=TRUE;
223  }
224 
225  return retval;
226 }
bool Insert(const string &s)
Definition: cccc_itm.cc:31
static const string MODULE_PREFIX
Definition: cccc_mod.h:35
string module_name
Definition: cccc_mod.h:48
string module_type
Definition: cccc_mod.h:48
T * first_item()
Definition: cccc_tbl.cc:118
T * next_item()
Definition: cccc_tbl.cc:124
Extent_Table extent_table
Definition: cccc_rec.h:45
int AddToItem(CCCC_Item &item)
Definition: cccc_ext.cc:64
static const string MODEXT_PREFIX
Definition: cccc_mod.h:36
bool ToFile(ofstream &ofstr)
Definition: cccc_itm.cc:112

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class CCCC_Html_Stream
friend

Definition at line 45 of file cccc_mod.h.

friend class CCCC_Project
friend

Definition at line 44 of file cccc_mod.h.

friend class CCCC_Xml_Stream
friend

Definition at line 46 of file cccc_mod.h.

Member Data Documentation

relationship_map_t CCCC_Module::client_map
private

Definition at line 54 of file cccc_mod.h.

member_map_t CCCC_Module::member_map
private

Definition at line 51 of file cccc_mod.h.

string CCCC_Module::module_name
private

Definition at line 48 of file cccc_mod.h.

string CCCC_Module::module_type
private

Definition at line 48 of file cccc_mod.h.

CCCC_Project* CCCC_Module::project
private

Definition at line 47 of file cccc_mod.h.

relationship_map_t CCCC_Module::supplier_map
private

Definition at line 55 of file cccc_mod.h.


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