00001
00002
00003
00004
00005
00006
00007 #ifndef __cmt_use_h__
00008 #define __cmt_use_h__
00009
00010 #include "cmt_map.h"
00011 #include "cmt_include.h"
00012 #include "cmt_script.h"
00013 #include "cmt_pattern.h"
00014 #include "cmt_scope_section.h"
00015
00016 class Package;
00017 class UseProjectAction;
00018
00019 class Use
00020 {
00021
00022 public:
00023 typedef cmt_vector<Use> UseVector;
00024 typedef cmt_vector<Use*> UsePtrVector;
00025
00026 static Use* action (const CmtSystem::cmt_string_vector& words, Use* use);
00027 static Use* find (const cmt_string& package,
00028 const cmt_string& version = "",
00029 const cmt_string& path = "");
00030 static int find_index (const cmt_string& package,
00031 const cmt_string& version,
00032 const cmt_string& path);
00033 static void set_auto_imports_state (int use_index,
00034 cmt_vector<bool>& auto_imports_states);
00035 static Use* add (const cmt_string& path,
00036 const cmt_string& package,
00037 const cmt_string& version,
00038 const cmt_string& version_alias,
00039 const cmt_string& path_alias,
00040 Use* context_use,
00041 State specified_auto_imports = Unspecified);
00042 static void move (Use* use1);
00043 static void reorder (Use* use1, Use* use2);
00044 static void select_clients (const cmt_string& package,
00045 const cmt_string& version);
00046 static void show_all (bool skip_discarded = false);
00047 static void show_all (const cmt_string& prefix, bool skip_discarded = false);
00048
00049 static Use& current ();
00050 static const Use& const_current ();
00051
00052 static UseVector& get_instances ();
00053 static UsePtrVector& get_ordered_uses ();
00054
00055 static void clear_all ();
00056 static void unselect_all ();
00057 static void undiscard_all ();
00058 static void fill_macro_all (cmt_string& buffer, const cmt_string& suffix);
00059
00060
00061 private:
00062 static Use* create (const cmt_string& path,
00063 const cmt_string& package,
00064 const cmt_string& version,
00065 const cmt_string& version_alias,
00066 const cmt_string& path_alias);
00067
00068
00069 public:
00070 Use ();
00071 Use (const cmt_string& new_package,
00072 const cmt_string& new_version,
00073 const cmt_string& new_path);
00074 ~Use ();
00075 void set (const cmt_string& new_package,
00076 const cmt_string& new_version,
00077 const cmt_string& new_path,
00078 const cmt_string& new_version_alias = "",
00079 const cmt_string& new_path_alias = "");
00080 void author_action (const CmtSystem::cmt_string_vector& words);
00081 void manager_action (const CmtSystem::cmt_string_vector& words);
00082 bool move_to ();
00083 void discard ();
00084 void undiscard ();
00085 void apply_global_patterns ();
00086 void set_include_path (const cmt_string& new_path);
00087 void get_full_path (cmt_string& s) const;
00088 cmt_string get_full_path () const;
00089 void reduce_path (cmt_string& s) const;
00090 void get_cmtpath_and_offset (cmt_string& cmtpath, cmt_string& offset) const;
00091
00092 void fill_includes_macro (cmt_string& buffer) const;
00093 void fill_macro (cmt_string& buffer, const cmt_string& suffix) const;
00094 void fill_standard_macros (cmt_string& buffer) const;
00095 void build_library_links (const cmt_string& cmtinstallarea,
00096 const cmt_string& tag,
00097 const cmt_string& shlibsuffix,
00098 const cmt_string& symlinkcmd) const;
00099
00100 bool get_all_clients (const cmt_string& to_name);
00101
00102 bool get_paths (Use* to, UsePtrVector& list);
00103
00104 bool located () const;
00105
00106 void change_path (const cmt_string& path);
00107 void set_auto_imports (State new_state);
00108 void set_native_version (bool state);
00109 bool has_native_version () const;
00110
00111 Package* get_package () const;
00112 const cmt_string& get_package_name () const;
00113 void set_package_name (const cmt_string& name);
00114
00115 int get_index () const;
00116
00117 void show_cycles ();
00118
00119 void push_scope_section (ScopeType type);
00120 void pop_scope_section ();
00121 void close_scope_sections ();
00122
00123 ScopeType get_current_scope () const;
00124
00125
00126 public:
00127
00128 cmt_string specified_version;
00129 cmt_string specified_path;
00130 cmt_string version_alias;
00131 cmt_string path_alias;
00132 cmt_string author;
00133 cmt_string manager;
00134
00135 cmt_string path;
00136 cmt_string version;
00137 cmt_string real_path;
00138 CmtDirStyle style;
00139
00140 cmt_string prefix;
00141 bool done;
00142
00143 bool discarded;
00144 bool selected;
00145
00146 State auto_imports;
00147
00148 Include::IncludeVector includes;
00149 cmt_string include_path;
00150 Script::ScriptVector scripts;
00151 ApplyPattern::ApplyPatternVector apply_patterns;
00152 IgnorePattern::IgnorePatternVector ignore_patterns;
00153
00154
00155 private:
00156 void clear ();
00157 int reach_package (const cmt_string& current_path);
00158 void select ();
00159 void unselect ();
00160 bool is_selected ();
00161 bool is_client (const cmt_string& package,
00162 const cmt_string& version);
00163 void show_sub_uses (const cmt_string& request, bool skip_discarded = false);
00164 bool select_alternate ();
00165 Use* get_selected_version ();
00166 Use* set_selected_version (Use* selected_use);
00167
00168 static bool need_new (const cmt_string& path,
00169 const cmt_string& package,
00170 const cmt_string& version,
00171 Use** old_use,
00172 Use* context_use);
00173
00174 bool get_all_clients (Use* to,
00175 const cmt_string& result,
00176 cmt_map <cmt_string, Use*>& all_clients,
00177 cmt_map <cmt_string, Use*>& all_clients_ok);
00178
00179
00180 private:
00181
00182 Package* m_package;
00183
00184
00185 bool m_located;
00186 bool m_has_native_version;
00187
00188 UsePtrVector sub_uses;
00189 cmt_vector<ScopeType> sub_use_scopes;
00190 cmt_vector<State> sub_use_auto_imports;
00191
00192 ScopeType initial_scope;
00193 cmt_vector<ScopeSection> scope_sections;
00194
00195 CmtSystem::cmt_string_vector alternate_versions;
00196 CmtSystem::cmt_string_vector alternate_paths;
00197
00198 CmtSystem::cmt_string_vector requests;
00199
00200 int m_index;
00201
00202 friend class UseProjectAction;
00203 };
00204
00205 class Package
00206 {
00207 public:
00208
00209 typedef cmt_map<cmt_string, Package> PackageMap;
00210 typedef cmt_vector<Package> PackageVector;
00211
00212 static Package* find (const cmt_string& name);
00213 static Package* add (const cmt_string& name);
00214
00215 static PackageVector& packages ();
00216 static PackageMap& package_map ();
00217
00218 static void clear_all ();
00219
00220 public:
00221
00222 Package ();
00223 ~Package ();
00224
00225 const cmt_string& get_name () const;
00226 void add_use (Use* use);
00227 void remove_use (Use* use);
00228 Use::UsePtrVector& get_uses ();
00229
00230 bool is_cmt ();
00231
00232 private:
00233 bool m_is_cmt;
00234
00235 cmt_string m_name;
00236 Use::UsePtrVector m_uses;
00237 };
00238
00239 #endif