OpenMPI  0.1.1
vt_libwrapgen_filter.h
1 /**
2  * VampirTrace
3  * http://www.tu-dresden.de/zih/vampirtrace
4  *
5  * Copyright (c) 2005-2012, ZIH, TU Dresden, Federal Republic of Germany
6  *
7  * Copyright (c) 1998-2005, Forschungszentrum Juelich, Juelich Supercomputing
8  * Centre, Federal Republic of Germany
9  *
10  * See the file COPYING in the package base directory for details
11  **/
12 
13 #ifndef _VT_LIBWRAPGEN_FILTER_H_
14 #define _VT_LIBWRAPGEN_FILTER_H_
15 
16 #include "util/util.h"
17 
18 #include <string>
19 #include <vector>
20 
21 #include <fnmatch.h> // :TODO: not portable!
22 #include <stdlib.h>
23 
24 // Filter class
25 //
26 class FilterC
27 {
28 public:
29 
30  // contructor
31  FilterC();
32 
33  // destructor
34  ~FilterC();
35 
36  // read filter file
37  bool read( void );
38 
39  // register function and check whether it shall be wrapped
40  bool constraint( const std::string& file, const std::string& funcName );
41 
42 private:
43 
44  // data structure for a filter entry
45  //
46  struct PatternS
47  {
48  PatternS(const std::string& _pattern, bool _allowed)
49  : pattern(_pattern), allowed(_allowed) {}
50 
51  std::string pattern;
52  bool allowed;
53 
54  bool operator==( const std::string& a ) const
55  {
56  return ( fnmatch( pattern.c_str(), a.c_str(), 0 ) == 0 );
57  }
58  };
59 
60  // trim leading and trailing spaces from a string
61  //
62  void trim( std::string& str )
63  {
64  size_t len = str.length();
65  if( len == 0 ) return;
66 
67  char* c_str = new char[len+1];
68 
69  str.copy( c_str, len );
70  c_str[len] = '\0';
71 
72  vt_strtrim( c_str );
73 
74  str = c_str;
75 
76  delete [] c_str;
77  }
78 
79  // vector of filter pattern
80  std::vector<PatternS> filtPattern;
81 
82 };
83 
84 #endif // _VT_LIBWRAPGEN_FILTER_H_
FilterC()
VampirTrace http://www.tu-dresden.de/zih/vampirtrace.
Definition: vt_libwrapgen_filter.cc:27
VampirTrace http://www.tu-dresden.de/zih/vampirtrace.
Definition: vt_libwrapgen_filter.h:26