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

#include <cccc_use.h>

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

Public Member Functions

string name (int index) const
 
 CCCC_UseRelationship (CCCC_Item &is)
 
int FromFile (ifstream &infile)
 
int ToFile (ofstream &outfile)
 
void add_extent (CCCC_Item &)
 
int get_count (const char *count_tag)
 
UseType get_usetype () const
 
AugmentedBool is_visible () const
 
AugmentedBool is_concrete () const
 
void generate_report (ostream &os)
 
CCCC_Modulesupplier_module_ptr (CCCC_Project *prj)
 
CCCC_Moduleclient_module_ptr (CCCC_Project *prj)
 
- Public Member Functions inherited from CCCC_Record
virtual ~CCCC_Record ()
 
virtual string key () const
 
AugmentedBool get_flag (PSFlag psf)
 
virtual void sort ()
 

Private Member Functions

 CCCC_UseRelationship ()
 

Private Attributes

string supplier
 
string client
 
string member
 
UseType ut
 
AugmentedBool visible
 
AugmentedBool concrete
 

Friends

class CCCC_Project
 

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 34 of file cccc_use.h.

Constructor & Destructor Documentation

CCCC_UseRelationship::CCCC_UseRelationship ( )
inlineprivate

Definition at line 40 of file cccc_use.h.

40 { ut=utDONTKNOW; }
CCCC_UseRelationship::CCCC_UseRelationship ( CCCC_Item is)

Definition at line 30 of file cccc_use.cc.

31 {
32  is.Extract(client);
33  is.Extract(member);
34  is.Extract(supplier);
37  ut=utDONTKNOW;
38 }
AugmentedBool concrete
Definition: cccc_use.h:39
bool Extract(string &s)
Definition: cccc_itm.cc:47
AugmentedBool visible
Definition: cccc_use.h:39

Here is the call graph for this function:

Member Function Documentation

void CCCC_UseRelationship::add_extent ( CCCC_Item is)
virtual

Reimplemented from CCCC_Record.

Definition at line 68 of file cccc_use.cc.

69 {
70  // processing is similar to the CCCC_Record method, except that we update
71  // the visibility and concreteness data members
72  // but do not do merge_flags
73  CCCC_Extent *new_extent=new CCCC_Extent(is);
74  CCCC_Extent *inserted_extent=extent_table.find_or_insert(new_extent);
75 
76  switch(new_extent->get_visibility())
77  {
78  case vPUBLIC:
79  case vPROTECTED:
81  break;
82  case vPRIVATE:
83  case vIMPLEMENTATION:
85  break;
86 
87  default:
88  // nothing required
89  ;;
90  }
91 
92  // a single relationship record represents all connections between two
93  // modules, hence it may have multiple extents which are of different use
94  // types
95  // the use type attached to the relationship record is used only to identify
96  // inheritance relationships
97  UseType new_ut=new_extent->get_usetype();
98  if(new_ut==utINHERITS)
99  {
100  ut=utINHERITS;
101  }
102 
103  switch(new_ut)
104  {
105  case utINHERITS:
106  case utHASBYVAL:
107  case utPARBYVAL:
108  case utVARBYVAL:
110  break;
111  default:
112  // no change required
113  ;;
114  }
115 
116  if(new_extent != inserted_extent)
117  {
118  delete new_extent;
119  }
120 }
AugmentedBool concrete
Definition: cccc_use.h:39
UseType
Definition: cccc_utl.h:65
UseType get_usetype() const
Definition: cccc_ext.h:57
T * find_or_insert(T *new_item_ptr)
Definition: cccc_tbl.cc:78
Extent_Table extent_table
Definition: cccc_rec.h:45
Visibility get_visibility() const
Definition: cccc_ext.h:55
AugmentedBool visible
Definition: cccc_use.h:39

Here is the call graph for this function:

Here is the caller graph for this function:

CCCC_Module * CCCC_UseRelationship::client_module_ptr ( CCCC_Project prj)

Definition at line 169 of file cccc_use.cc.

170 {
171  return prj->module_table.find(client.c_str());
172 }
CCCC_Table< CCCC_Module > module_table
Definition: cccc_prj.h:54
T * find(string name)
Definition: cccc_tbl.cc:66

Here is the call graph for this function:

int CCCC_UseRelationship::FromFile ( ifstream &  infile)

Definition at line 206 of file cccc_use.cc.

207 {
208  int retval;
209  CCCC_Item next_line;
210  next_line.FromFile(ifstr);
211  ifstr_line++;
212 
213  string line_keyword_dummy;
214 
215  CCCC_UseRelationship *found_uptr=NULL;
216 
217  if(
218  next_line.Extract(line_keyword_dummy) &&
219  next_line.Extract(this->supplier) &&
220  next_line.Extract(this->client)
221  )
222  {
223  found_uptr=
225  if(found_uptr==this)
226  {
227  // the newly created instance of the module is the first
228  // and has taken its place in the database, so we protect
229  // it from deletion
230  retval=RECORD_ADDED;
231  }
232  else
233  {
234  retval=RECORD_TRANSCRIBED;
235  }
236 
237  // process extent records
238  while(PeekAtNextLinePrefix(ifstr,USEEXT_PREFIX))
239  {
240  CCCC_Extent *new_extent=new CCCC_Extent;
241  next_line.FromFile(ifstr);
242  ifstr_line++;
243  string supplier_dummy, client_dummy;
244 
245  if(
246  next_line.Extract(line_keyword_dummy) &&
247  next_line.Extract(supplier_dummy) &&
248  next_line.Extract(client_dummy) &&
249  new_extent->GetFromItem(next_line)
250  )
251  {
252  // We don't ever expect to find duplicated extent records
253  // but just in case...
254  CCCC_Extent *found_eptr=
255  found_uptr->extent_table.find_or_insert(new_extent);
256  if(found_eptr!=new_extent)
257  {
258  cerr << "Failed to add extent for relationship "
259  << found_uptr->key() << " at line " << ifstr_line
260  << endl;
261  delete new_extent;
262  }
263  }
264  }
265 
266  }
267  else // extraction of module intial line failed
268  {
269  // unexpected problem with the input
270  retval=RECORD_ERROR;
271  }
272 
273  // If the import was successful, we will also have imported all dependent
274  // extent records following the main record.
275  // If not, we must skip them.
276  while(PeekAtNextLinePrefix(ifstr,USEEXT_PREFIX))
277  {
278  CCCC_Item next_line;
279  next_line.FromFile(ifstr);
280  ifstr_line++;
281  cerr << "Ignoring userel extent on line " << ifstr_line << endl;
282  }
283 
284  return retval;
285 }
virtual string key() const
Definition: cccc_rec.cc:76
int ifstr_line
Definition: cccc_db.cc:32
static const string USEEXT_PREFIX
Definition: cccc_use.h:30
bool Extract(string &s)
Definition: cccc_itm.cc:47
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
CCCC_Table< CCCC_UseRelationship > userel_table
Definition: cccc_prj.h:56
Extent_Table extent_table
Definition: cccc_rec.h:45
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:

void CCCC_UseRelationship::generate_report ( ostream &  os)
int CCCC_UseRelationship::get_count ( const char *  count_tag)
virtual

Implements CCCC_Record.

Definition at line 122 of file cccc_use.cc.

123 {
124  int retval=0;
125 
126  if( (strncmp(count_tag,"FI",2)==0) || (strncmp(count_tag,"FO",2)==0) )
127  {
128  char suffix=count_tag[2];
129  switch(suffix)
130  {
131  case 0:
132  retval=1;
133  break;
134 
135  case 'v':
136  if(visible!=abFALSE)
137  {
138  retval=1;
139  }
140  break;
141 
142  case 'c':
143  if(concrete!=abFALSE)
144  {
145  retval=1;
146  }
147  break;
148 
149  default:
150  cerr << "Unexpected count tag suffix" << count_tag << endl;
151  }
152  }
153  else
154  {
155  cerr << "Unexpected count tag " << count_tag << endl;
156  }
157 
158 
159  return retval;
160 }
AugmentedBool concrete
Definition: cccc_use.h:39
AugmentedBool visible
Definition: cccc_use.h:39
UseType CCCC_UseRelationship::get_usetype ( ) const
inline

Definition at line 49 of file cccc_use.h.

49 { return ut; }
AugmentedBool CCCC_UseRelationship::is_concrete ( ) const
inline

Definition at line 51 of file cccc_use.h.

51 { return concrete; }
AugmentedBool concrete
Definition: cccc_use.h:39

Here is the caller graph for this function:

AugmentedBool CCCC_UseRelationship::is_visible ( ) const
inline

Definition at line 50 of file cccc_use.h.

50 { return visible; }
AugmentedBool visible
Definition: cccc_use.h:39

Here is the caller graph for this function:

string CCCC_UseRelationship::name ( int  index) const
virtual

Reimplemented from CCCC_Record.

Definition at line 40 of file cccc_use.cc.

41 {
42  string namestr;
43 
44  switch(name_level)
45  {
46  case nlRANK:
47  case nlSIMPLE:
48  namestr.append(client);
49  namestr.append(" uses ");
50  namestr.append(supplier);
51  break;
52 
53  case nlSUPPLIER:
54  namestr=supplier;
55  break;
56 
57  case nlCLIENT:
58  namestr=client;
59  break;
60 
61  default:
62  cerr << "unexpected name level" << endl;
63  }
64 
65  return namestr.c_str();
66 }

Here is the caller graph for this function:

CCCC_Module * CCCC_UseRelationship::supplier_module_ptr ( CCCC_Project prj)

Definition at line 164 of file cccc_use.cc.

165 {
166  return prj->module_table.find(supplier.c_str());
167 }
CCCC_Table< CCCC_Module > module_table
Definition: cccc_prj.h:54
T * find(string name)
Definition: cccc_tbl.cc:66

Here is the call graph for this function:

int CCCC_UseRelationship::ToFile ( ofstream &  outfile)

Definition at line 175 of file cccc_use.cc.

176 {
177  int retval=FALSE;
178 
179  CCCC_Item line;
180  line.Insert(USEREL_PREFIX);
181  line.Insert(supplier);
182  line.Insert(client);
183  line.ToFile(ofstr);
184 
185  CCCC_Extent *extent_ptr=extent_table.first_item();
186  while(extent_ptr!=NULL)
187  {
188  CCCC_Item extent_line;
189  extent_line.Insert(USEEXT_PREFIX);
190  extent_line.Insert(supplier);
191  extent_line.Insert(client);
192  extent_ptr->AddToItem(extent_line);
193  extent_line.ToFile(ofstr);
194 
195  extent_ptr=extent_table.next_item();
196  }
197 
198  if(ofstr.good())
199  {
200  retval=TRUE;
201  }
202 
203  return retval;
204 }
bool Insert(const string &s)
Definition: cccc_itm.cc:31
static const string USEEXT_PREFIX
Definition: cccc_use.h:30
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 USEREL_PREFIX
Definition: cccc_use.h:29
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_Project
friend

Definition at line 36 of file cccc_use.h.

Member Data Documentation

string CCCC_UseRelationship::client
private

Definition at line 37 of file cccc_use.h.

AugmentedBool CCCC_UseRelationship::concrete
private

Definition at line 39 of file cccc_use.h.

string CCCC_UseRelationship::member
private

Definition at line 37 of file cccc_use.h.

string CCCC_UseRelationship::supplier
private

Definition at line 37 of file cccc_use.h.

UseType CCCC_UseRelationship::ut
private

Definition at line 38 of file cccc_use.h.

AugmentedBool CCCC_UseRelationship::visible
private

Definition at line 39 of file cccc_use.h.


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