00001 #ifndef __cmt_use_h__
00002 #define __cmt_use_h__
00003
00004 #include "cmt_include.h"
00005 #include "cmt_script.h"
00006 #include "cmt_pattern.h"
00007
00008 class Use
00009 {
00010 public:
00011 typedef cmt_vector<Use> UseVector;
00012 typedef cmt_vector<Use*> UsePtrVector;
00013
00014 static Use* action (const CmtSystem::cmt_string_vector& words, Use* use);
00015 static Use* find (const cmt_string& package,
00016 const cmt_string& version = "",
00017 const cmt_string& path = "");
00018 static Use* add (const cmt_string& path,
00019 const cmt_string& package,
00020 const cmt_string& version,
00021 const cmt_string& version_alias,
00022 const cmt_string& path_alias,
00023 Use* context_use,
00024 State specified_auto_imports = Unspecified);
00025 static void move (Use* use1);
00026 static void reorder (Use* use1, Use* use2);
00027 static void select_clients (const cmt_string& package,
00028 const cmt_string& version);
00029 static void show_all (bool skip_discarded = false);
00030 static void show_all (const cmt_string& prefix, bool skip_discarded = false);
00031 static Use& current ();
00032 static const Use& const_current ();
00033 static UseVector& all_uses ();
00034 static UsePtrVector& uses ();
00035 static void clear_all ();
00036 static void unselect_all ();
00037 static void undiscard_all ();
00038 static void fill_macro_all (cmt_string& buffer, const cmt_string& suffix);
00039
00040 private:
00041 static Use* create (const cmt_string& path,
00042 const cmt_string& package,
00043 const cmt_string& version,
00044 const cmt_string& version_alias,
00045 const cmt_string& path_alias);
00046
00047 public:
00048 Use ();
00049 Use (const cmt_string& new_package,
00050 const cmt_string& new_version,
00051 const cmt_string& new_path);
00052 ~Use ();
00053 void set (const cmt_string& new_package,
00054 const cmt_string& new_version,
00055 const cmt_string& new_path,
00056 const cmt_string& new_version_alias = "",
00057 const cmt_string& new_path_alias = "");
00058 void author_action (const CmtSystem::cmt_string_vector& words);
00059 void manager_action (const CmtSystem::cmt_string_vector& words);
00060 bool move_to ();
00061 void discard ();
00062 void undiscard ();
00063 void apply_global_patterns ();
00064 void set_include_path (const cmt_string& new_path);
00065
00066 void fill_includes_macro (cmt_string& buffer) const;
00067 void fill_macro (cmt_string& buffer, const cmt_string& suffix) const;
00068
00069 bool get_paths (Use* to, UsePtrVector& list);
00070
00071 bool located () const;
00072
00073 void change_path (const cmt_string& path);
00074 void set_auto_imports (State new_state);
00075 void set_native_version (bool state);
00076 bool has_native_version () const;
00077
00078 cmt_string package;
00079 cmt_string specified_version;
00080 cmt_string specified_path;
00081 cmt_string version_alias;
00082 cmt_string path_alias;
00083 cmt_string author;
00084 cmt_string manager;
00085
00086 cmt_string path;
00087 cmt_string version;
00088 cmt_string real_path;
00089 CmtDirStyle style;
00090
00091 cmt_string prefix;
00092 ScopeType scope;
00093 bool done;
00094
00095 bool discarded;
00096 bool selected;
00097
00098 State auto_imports;
00099
00100 Include::IncludeVector includes;
00101 cmt_string include_path;
00102 Script::ScriptVector scripts;
00103 ApplyPattern::ApplyPatternVector apply_patterns;
00104 IgnorePattern::IgnorePatternVector ignore_patterns;
00105
00106 private:
00107 void clear ();
00108 int reach_package (const cmt_string& current_path);
00109 void select ();
00110 void unselect ();
00111 bool is_selected ();
00112 bool is_client (const cmt_string& package,
00113 const cmt_string& version);
00114 void show_sub_uses (bool skip_discarded = false);
00115 bool select_alternate ();
00116 Use* get_selected_version ();
00117
00118 static bool need_new (const cmt_string& path,
00119 const cmt_string& package,
00120 const cmt_string& version,
00121 Use** old_use);
00122
00123 bool m_located;
00124 bool m_has_native_version;
00125
00126 UsePtrVector sub_uses;
00127 cmt_vector<ScopeType> sub_use_scopes;
00128 cmt_vector<State> sub_use_auto_imports;
00129
00130 CmtSystem::cmt_string_vector alternate_versions;
00131 CmtSystem::cmt_string_vector alternate_paths;
00132 };
00133
00134 #endif