name_storage.h

Go to the documentation of this file.
00001 
00012 #ifndef NAME_STORAGE_H
00013 #define NAME_STORAGE_H
00014 
00015 #include <string>
00016 
00017 #include "unique_storage.h"
00018 
00019 class extra_images;
00020 
00022 struct stored_name {
00023     stored_name(std::string const & n = std::string())
00024         : name(n) {}
00025 
00026     bool operator<(stored_name const & rhs) const {
00027         return name < rhs.name;
00028     }
00029 
00030     std::string name;
00031     mutable std::string name_processed;
00032 };
00033 
00034 
00036 template <typename I> struct name_storage : unique_storage<I, stored_name> {
00037 
00038     typedef typename unique_storage<I, stored_name>::id_value id_value;
00039 
00040     std::string const & name(id_value const & id) const {
00041         return unique_storage<I, stored_name>::get(id).name;
00042     }
00043 };
00044 
00045 
00046 class debug_name_tag;
00048 typedef name_storage<debug_name_tag>::id_value debug_name_id;
00049 
00051 struct debug_name_storage : name_storage<debug_name_tag> {
00053     std::string const & basename(debug_name_id id) const;
00054 };
00055 
00057 struct stored_filename {
00058     stored_filename(std::string const & n = std::string())
00059         : filename(n), extra_images_uid(0) {}
00060 
00061     bool operator<(stored_filename const & rhs) const {
00062         return filename < rhs.filename;
00063     }
00064 
00065     std::string filename;
00066     mutable std::string base_filename;
00067     mutable std::string real_filename;
00068     mutable std::string real_base_filename;
00069     mutable int extra_images_uid;
00070 };
00071 
00073 template <typename I> 
00074 struct filename_storage : unique_storage<I, stored_filename> {
00075 
00076     typedef typename unique_storage<I, stored_filename>::id_value id_value;
00077 
00078     std::string const & name(id_value const & id) const {
00079         return unique_storage<I, stored_filename>::get(id).filename;
00080     }
00081 };
00082 
00083 class image_name_tag;
00085 typedef filename_storage<image_name_tag>::id_value image_name_id;
00086 
00088 struct image_name_storage : filename_storage<image_name_tag> {
00089     enum image_name_type {
00091         int_basename,
00093         int_filename,
00095         int_real_basename,
00098         int_real_filename,
00099     };
00100 
00114     std::string const & get_name(image_name_id id,
00115                      image_name_type type,
00116                      extra_images const & extra) const;
00117 
00119     std::string const & basename(image_name_id) const;
00120 };
00121 
00122 
00123 class symbol_name_tag;
00125 typedef name_storage<symbol_name_tag>::id_value symbol_name_id;
00126 
00128 struct symbol_name_storage : name_storage<symbol_name_tag> {
00130     std::string const & demangle(symbol_name_id id) const;
00131 };
00132 
00133 
00135 extern image_name_storage image_names;
00136 
00138 extern debug_name_storage debug_names;
00139 
00141 extern symbol_name_storage symbol_names;
00142 
00143 
00153 template<> inline bool
00154 debug_name_id::operator<(debug_name_id const & rhs) const
00155 {
00156     return debug_names.name(*this) < debug_names.name(rhs);
00157 }
00158 
00159 #endif /* !NAME_STORAGE_H */

Generated on 8 Nov 2012 for Oprofile by  doxygen 1.6.1