00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include "vcg.h"
00042
00043 vcgWalker::vcgWalker(ostream& ostr, const string& comment,
00044 string excludefilename)
00045 : Walker( Both, Subtree ), graph(ostr), currently_excluded(false) {
00046 #ifdef J_BREEZE
00047 current_type.clear();
00048 #endif
00049 exclude.clear();
00050
00051
00052
00053 if( ! excludefilename.empty() ) {
00054 ifstream excludefile(excludefilename.c_str());
00055 if(! excludefile.is_open()) {
00056 cerr << "exclude file " << excludefilename << " cannot be opened\n";
00057 exit(1);
00058 } else {
00059 string name;
00060 while( excludefile >> name )
00061 exclude.push_back(name);
00062 }
00063 }
00064
00065 }
00066
00067 #ifdef J_BREEZE
00068 bool vcgWalker::excluded(typeNode *type) {
00069 if(!type || (type->typ()!=Class && type->typ()!=Interface)) return true;
00070 if(type->coord().line() == Coord::Unknown.line()) return true;
00071 string name = typenameNode::type_name(type);
00072 packageNode *p = packageNode::packageOf(type);
00073 string pname = p->fullname();
00074 string fullname = pname + "." + name;
00075
00076
00077 for(strings::iterator s=exclude.begin(); s!=exclude.end(); s++)
00078 if(*s==name || *s==pname || *s==fullname) return true;
00079 return false;
00080 }
00081 #else
00082 bool vcgWalker::excluded(procNode *proc) {
00083 string name = proc->decl()->name();
00084
00085
00086 return find(exclude.begin(), exclude.end(), name) != exclude.end();
00087 }
00088
00089 bool vcgWalker::excluded(Coord coord) {
00090 if(coord.line() == Coord::Unknown.line()) return false;
00091 string filename = coord.filename();
00092
00093
00094 return find(exclude.begin(), exclude.end(), filename) != exclude.end();
00095 }
00096 #endif
00097
00098 #ifdef J_BREEZE
00099 void vcgWalker::at_type(typeNode *type, Order order) {
00100 if(type->typ()!=Class && type->typ()!=Interface) return;
00101 if(order==Preorder) current_type.push_front(type);
00102 else current_type.pop_front();
00103 if(current_type.empty())
00104 currently_excluded = true;
00105 else
00106 currently_excluded = excluded(current_type.front());
00107 }
00108 #else
00109 void vcgWalker::at_proc(procNode *proc, Order order) {
00110 if(order==Postorder) currently_excluded = false;
00111 else currently_excluded = excluded(proc);
00112 }
00113 #endif
00114
00115 void vcgWalker::print_comment(const string& comment) {
00116 graph << "// " << comment << endl; }
00117
00118 void vcgWalker::print_graph_attribute(const string& attribute,
00119 const string& value) {
00120 graph << endl;
00121 graph << " " << attribute << " : " << value << endl;
00122 }
00123
00124 void vcgWalker::print_node_attribute(const string& attribute,
00125 const string& value) {
00126 graph << "\t" << attribute << ": \"" << value << "\"" << endl;
00127 }
00128 void vcgWalker::print_node_attribute(const string& attribute, int value) {
00129 graph << "\t" << attribute << ": " << value << endl;
00130 }
00131
00132 void vcgWalker::print_node_value(const string& attribute, const string& value) {
00133 graph << "\t" << attribute << ": " << value << endl;
00134 };
00135