cmt_database.cxx Source File

Main Page Class Hierarchy Compound List File List Compound Members File Members

# cmt_database.cxx

Go to the documentation of this file.

    00001
    00002 #include "cmt_database.h"
    00003 #include "cmt_vector.h"
    00004
    00005 template <class T>
    00006 class dumper
    00007 {
    00008 public :
    00009   void dump_vector (const cmt_vector<T>& vector,
    00010                     const cmt_string& title)
    00011       {
    00012         int i;
    00013
    00014         {
    00015             //const cmt_vector<T>::frame_ptr frame = vector.get_frame ();
    00016           T** frame = vector.get_frame ();
    00017
    00018           cout << title << " frame=" << frame << " size=" << vector.size () << endl;
    00019
    00020           int element = 0;
    00021
    00022           for (i = 0; i < vector.get_frame_number (); i++)
    00023             {
    00024                 //cmt_vector<T>::element_ptr ptr = frame[i];
    00025               T* ptr = frame[i];
    00026               for (int j = 0; j < vector.get_frame_size (); j++)
    00027                 {
    00028                   element++;
    00029                   if (element >= vector.size ()) break;
    00030
    00031                   cout << "   frame[" << i << "][" << j << "]=" << &ptr[j] << endl;
    00032                 }
    00033
    00034               if (element >= vector.size ()) break;
    00035             }
    00036         }
    00037       }
    00038 };
    00039
    00040 Database& Database::instance ()
    00041 {
    00042   static Database db;
    00043
    00044   return (db);
    00045 }
    00046
    00047 void Database::dump (const cmt_string& title,
    00048                      keys key_set)
    00049 {
    00050   static Database& db = instance ();
    00051   static dumper<Branch> branch_dumper;
    00052   static dumper<Constituent> constituent_dumper;
    00053   static dumper<Fragment> fragment_dumper;
    00054   static dumper<Group> group_dumper;
    00055   static dumper<Language> language_dumper;
    00056   static dumper<Pattern> pattern_dumper;
    00057   static dumper<Tag> tag_dumper;
    00058   static dumper<Use> use_dumper;
    00059   static dumper<Symbol> symbol_dumper;
    00060
    00061   cout << "Database>-------------" << title << endl;
    00062
    00063   if ((key_set & key_branch) != 0) branch_dumper.dump_vector (db.m_branches, "Branches");
    00064   if ((key_set & key_constituent) != 0) constituent_dumper.dump_vector (db.m_constituents, "Constituents");
    00065   if ((key_set & key_fragment) != 0) fragment_dumper.dump_vector (db.m_fragments, "Fragments");
    00066   if ((key_set & key_group) != 0) group_dumper.dump_vector (db.m_groups, "Groups");
    00067   if ((key_set & key_language) != 0) language_dumper.dump_vector (db.m_languages, "Languages");
    00068   if ((key_set & key_pattern) != 0) pattern_dumper.dump_vector (db.m_patterns, "Patterns");
    00069   if ((key_set & key_tag) != 0) tag_dumper.dump_vector (db.m_all_tags, "AllTags");
    00070   if ((key_set & key_use) != 0) use_dumper.dump_vector (db.m_all_uses, "Uses");
    00071   if ((key_set & key_symbol) != 0) symbol_dumper.dump_vector (db.m_symbols, "Symbols");
    00072
    00073   cout << "Database>-------------" << endl;
    00074 }
    00075
    00076 void Database::clear ()
    00077 {
    00078   Branch::clear_all ();
    00079   Constituent::clear_all ();
    00080   Fragment::clear_all ();
    00081   Group::clear_all ();
    00082   Language::clear_all ();
    00083   Pattern::clear_all ();
    00084   Tag::clear_all ();
    00085   Use::clear_all ();
    00086   Symbol::clear_all ();
    00087 }
    00088
    00089 Branch::BranchVector& Database::branches ()
    00090 {
    00091   static Database& db = instance ();
    00092
    00093   return (db.m_branches);
    00094 }
    00095
    00096 Constituent::ConstituentVector& Database::constituents ()
    00097 {
    00098   static Database& db = instance ();
    00099
    00100   return (db.m_constituents);
    00101 }
    00102
    00103 Fragment::FragmentVector& Database::fragments ()
    00104 {
    00105   static Database& db = instance ();
    00106
    00107   return (db.m_fragments);
    00108 }
    00109
    00110 Group::GroupVector& Database::groups ()
    00111 {
    00112   static Database& db = instance ();
    00113
    00114   return (db.m_groups);
    00115 }
    00116
    00117 Language::LanguageVector& Database::languages ()
    00118 {
    00119   static Database& db = instance ();
    00120
    00121   return (db.m_languages);
    00122 }
    00123
    00124 Pattern::PatternVector& Database::patterns ()
    00125 {
    00126   static Database& db = instance ();
    00127
    00128   return (db.m_patterns);
    00129 }
    00130
    00131 Tag::TagVector& Database::all_tags ()
    00132 {
    00133   static Database& db = instance ();
    00134
    00135   return (db.m_all_tags);
    00136 }
    00137
    00138 Tag::TagPtrVector& Database::tags ()
    00139 {
    00140   static Database& db = instance ();
    00141
    00142   return (db.m_tags);
    00143 }
    00144
    00145 Use::UseVector& Database::all_uses ()
    00146 {
    00147   static Database& db = instance ();
    00148
    00149   return (db.m_all_uses);
    00150 }
    00151
    00152 Use::UsePtrVector& Database::uses ()
    00153 {
    00154   static Database& db = instance ();
    00155
    00156   return (db.m_uses);
    00157 }
    00158
    00159 Symbol::SymbolVector& Database::symbols ()
    00160 {
    00161   static Database& db = instance ();
    00162
    00163   return (db.m_symbols);
    00164 }
    00165
    00166 Database::Database ()
    00167 {
    00168 }
    00169