00001 //----------------------------------------------------------- 00002 // Copyright Christian Arnault LAL-Orsay CNRS 00003 // arnault@lal.in2p3.fr 00004 // See the complete license in cmt_license.txt "http://www.cecill.info". 00005 //----------------------------------------------------------- 00006 00007 #ifndef __cmt_tag_h__ 00008 #define __cmt_tag_h__ 00009 00010 #include "cmt_parser.h" 00011 #include "cmt_system.h" 00012 #include "cmt_use.h" 00013 #include "cmt_map.h" 00014 00015 class Tag 00016 { 00017 public: 00018 typedef cmt_map<cmt_string, Tag> TagMap; 00019 typedef cmt_vector<Tag> TagVector; 00020 typedef cmt_vector<Tag*> TagPtrVector; 00021 00022 static void action (const CmtSystem::cmt_string_vector& words, Use* use); 00023 static void action_apply (const CmtSystem::cmt_string_vector& words, Use* use); 00024 static void action_exclude (const CmtSystem::cmt_string_vector& words, Use* use); 00025 static Tag* find (const cmt_string& name, TagMap& instances); 00026 static Tag* find (const cmt_string& name); 00027 static Tag* add (const cmt_string& name, int priority, 00028 const cmt_string& context, Use* use = 0); 00029 static int tag_number (); 00030 static Tag* tag (int index); 00031 static void unmark_all (); 00032 static void restore_tree (); 00033 static void clear_all (); 00034 00035 static TagMap& tag_map (); 00036 static TagVector& all_tags (); 00037 static TagPtrVector& tags (); 00038 00039 static Tag* get_default (); 00040 00041 static bool check_tag_used (const Tag* tag); 00042 00043 public: 00044 Tag (); 00045 Tag (const Tag& other); 00046 Tag& operator = (const Tag& other); 00047 ~Tag (); 00048 void clear (); 00049 void add_tag_ref (Tag* ref); 00050 void add_tag_exclude (Tag* ref); 00051 void unmark (); 00052 void mark (); 00053 void show_definition (bool quiet) const; 00054 void show (bool quiet) const; 00055 bool is_selected () const; 00056 bool is_primary () const; 00057 const cmt_string& get_name () const; 00058 int get_priority () const; 00059 void install (TagMap& instances); 00060 bool use_operand (const Tag* other) const; 00061 bool use_ref (const Tag* other) const; 00062 00063 private: 00064 cmt_string m_name; 00065 bool m_selected; 00066 TagPtrVector m_and_operands; 00067 TagPtrVector m_tag_refs; 00068 TagPtrVector m_tag_excludes; 00069 cmt_string m_context; 00070 Use* m_def_use; 00071 Use* m_set_use; 00072 int m_priority; 00073 }; 00074 00075 #endif