NumberSinks Class Reference

#include <Metric.h>

Inheritance diagram for NumberSinks:

Inheritance graph
[legend]
Collaboration diagram for NumberSinks:

Collaboration graph
[legend]

Detailed Description

Definition at line 114 of file Metric.h.


Public Member Functions

 NumberSinks ()
 NumberSinks (const std::list< std::string > &sinks, const Ast *_ast=0)
virtual ~NumberSinks ()
virtual MetricResult operator() (const tree< AstNode > &, const MapClasses *classes=0, const MapVariables *vars=0, const MapFunctions *func=0, const MapAssignments *assigns=0, const MapVarEquivalent *equiv=0)

Data Fields

std::list< std::string > sensitive
const Astast

Constructor & Destructor Documentation

NumberSinks::NumberSinks (  )  [inline]

Definition at line 120 of file Metric.h.

00120 {}

NumberSinks::NumberSinks ( const std::list< std::string > &  sinks,
const Ast _ast = 0 
) [inline]

Definition at line 121 of file Metric.h.

References ast, and sensitive.

00121                                                                       {
00122         sensitive = sinks;
00123         ast = _ast;
00124     }

virtual NumberSinks::~NumberSinks (  )  [inline, virtual]

Definition at line 125 of file Metric.h.

00125 {}


Member Function Documentation

MetricResult NumberSinks::operator() ( const tree< AstNode > &  tr,
const MapClasses classes = 0,
const MapVariables vars = 0,
const MapFunctions func = 0,
const MapAssignments assigns = 0,
const MapVarEquivalent equiv = 0 
) [virtual]

Implements Metric.

Definition at line 56 of file Metric.cpp.

References ast, tree< T, tree_node_allocator >::begin(), tree< T, tree_node_allocator >::end(), Ast::getBoxedFunctions(), MetricResult::main, sensitive, and utils::start_with().

00058 {
00059     MetricResult  result;
00060     NumericResult num;
00061     unsigned n = 0;
00062     // Get the outputs functions in the tree-functions. if there is one, just add the function into the list of sensitive
00063     std::map<std::string, BoxedFunction> boxedFunctions = ast->getBoxedFunctions();
00064     for (std::map<std::string, BoxedFunction>::iterator iter=boxedFunctions.begin();iter!=boxedFunctions.end();++iter)
00065     {
00066         // iterate through the boxedFunctions output
00067         bool add = false;
00068         for(MapFunctions::iterator jter=iter->second.output.begin();jter!=iter->second.output.end();++jter) {
00069             if (find(sensitive.begin(), sensitive.end(), jter->first) != sensitive.end()) {
00070                 add = true;
00071                 break;
00072             }
00073         }
00074         if (add) {
00075             if (find(sensitive.begin(), sensitive.end(), iter->first) == sensitive.end())
00076                 sensitive.push_back(iter->first);
00077         }
00078     }
00079 
00080     // return the number of functions in the current source code
00081     for (tree<AstNode>::iterator iter = tr.begin(); iter != tr.end(); ++iter) {
00082         string t = iter->getType();
00083         if (t == "unticked_function_declaration_statement") {
00084             iter = tr.end(iter);
00085         }
00086         else if (t == "function_call") {
00087             tree<AstNode>::iterator son = tr.begin(iter);
00088             if (son->getType() == "T_STRING") {
00089                 tree<AstNode>::iterator  textable = tr.begin(son);
00090                 if (textable->getType() == "text" && find(sensitive.begin(), sensitive.end(), textable->getValue()) != sensitive.end()) {
00091                     n++;
00092                 }
00093             }
00094         }
00095         else if (t == "unticked_statement" || t == "expr_without_variable") {
00096             tree<AstNode>::iterator son = tr.begin(iter);
00097             if (utils::start_with(son->getType(), "T_")) {
00098                 tree<AstNode>::iterator  textable = tr.begin(son);
00099                 if (textable->getType() == "text" && find(sensitive.begin(), sensitive.end(), textable->getValue()) != sensitive.end()) {
00100                     n++;
00101                 }
00102             }
00103         }
00104     }
00105     num = n;
00106     result.main = num;
00107     return result;
00108 }

Here is the call graph for this function:


Field Documentation

std::list<std::string> NumberSinks::sensitive

Definition at line 117 of file Metric.h.

Referenced by NumberSinks(), and operator()().

const Ast* NumberSinks::ast

Definition at line 118 of file Metric.h.

Referenced by NumberSinks(), and operator()().


The documentation for this class was generated from the following files:
Generated on Wed Feb 27 20:32:10 2008 for php.ast.svn.src. by  doxygen 1.5.3