filename_spec.cpp

Go to the documentation of this file.
00001 
00011 #include <string>
00012 
00013 #include "filename_spec.h"
00014 #include "parse_filename.h"
00015 #include "generic_spec.h"
00016 #include "locate_images.h"
00017 
00018 
00019 using namespace std;
00020 
00021 
00022 filename_spec::filename_spec(string const & filename,
00023                  extra_images const & extra)
00024 {
00025     set_sample_filename(filename, extra);
00026 }
00027 
00028 
00029 filename_spec::filename_spec()
00030     : image("*"), lib_image("*")
00031 {
00032 }
00033 
00034 
00035 bool filename_spec::match(filename_spec const & rhs,
00036                           string const & binary) const
00037 {
00038     if (!tid.match(rhs.tid) || !cpu.match(rhs.cpu) ||
00039         !tgid.match(rhs.tgid) || count != rhs.count ||
00040         unitmask != rhs.unitmask || event != rhs.event) {
00041         return false;
00042     }
00043 
00044     if (binary.empty())
00045         return image == rhs.image && lib_image == rhs.lib_image;
00046 
00047     // PP:3.3 if binary is not empty we must match either the
00048     // lib_name if present or the image name
00049     if (!rhs.lib_image.empty()) {
00050         // FIXME: use fnmatch ?
00051         return rhs.lib_image == binary;
00052     }
00053 
00054     // FIXME: use fnmatch ?
00055     return rhs.image == binary;
00056 }
00057 
00058 
00059 void filename_spec::set_sample_filename(string const & filename,
00060     extra_images const & extra)
00061 {
00062     parsed_filename parsed = parse_filename(filename, extra);
00063 
00064     image = parsed.image;
00065     lib_image = parsed.lib_image;
00066     cg_image = parsed.cg_image;
00067     event = parsed.event;
00068     count = op_lexical_cast<int>(parsed.count);
00069     unitmask = op_lexical_cast<unsigned int>(parsed.unitmask);
00070     tgid.set(parsed.tgid);
00071     tid.set(parsed.tid);
00072     cpu.set(parsed.cpu);
00073 }
00074 
00075 
00076 bool filename_spec::is_dependent() const
00077 {
00078     if (cg_image.empty())
00079         return image != lib_image;
00080     return cg_image != image || cg_image != lib_image;
00081 }

Generated on 8 Nov 2012 for Oprofile by  doxygen 1.6.1