source: CMT/HEAD/source/cmt_use.h @ 588

Last change on this file since 588 was 588, checked in by rybkin, 13 years ago

See C.L. 465

  • Property svn:eol-style set to native
File size: 9.7 KB
Line 
1//-----------------------------------------------------------
2// Copyright Christian Arnault LAL-Orsay CNRS
3// arnault@lal.in2p3.fr
4// Modified by garonne@lal.in2p3.fr
5// See the complete license in cmt_license.txt "http://www.cecill.info".
6//-----------------------------------------------------------
7
8#ifndef __cmt_use_h__
9#define __cmt_use_h__
10
11#include "cmt_map.h"
12#include "cmt_include.h"
13#include "cmt_script.h"
14#include "cmt_pattern.h"
15#include "cmt_scope_section.h"
16
17class Package;
18class UseProjectAction;
19
20class Use
21{
22// Public class methods
23public:
24  typedef cmt_vector<Use> UseVector;
25  typedef cmt_vector<Use*> UsePtrVector;
26
27  static Use* action (const CmtSystem::cmt_string_vector& words, Use* use);
28  static Use* find (const cmt_string& package,
29                    const cmt_string& version = "",
30                    const cmt_string& path = "");
31  static int find_index (const cmt_string& package, 
32                         const cmt_string& version, 
33                         const cmt_string& path);
34  static Use* find_valid (const cmt_string& package);
35  //static void set_auto_imports_state (int use_index,
36  //cmt_vector<bool>& auto_imports_states);
37  static void set_auto_imports_state (const Use::UsePtrVector& uses,
38                                      cmt_vector<bool>& auto_imports_states);
39  static void set_auto_imports_state (const Use::UsePtrVector& uses,
40                                      cmt_vector<bool>& auto_imports_states,
41                                      cmt_map <Use*, bool>& visited);
42  static Use* add (const cmt_string& path,
43                   const cmt_string& package,
44                   const cmt_string& version,
45                   const cmt_string& version_alias,
46                   const cmt_string& path_alias,
47                   const cmt_string& native_version,
48                   Use* context_use,
49                   const State specified_auto_imports = Unspecified);
50  static void move (Use* use1);
51  static void reorder (Use* use1, Use* use2);
52  static void select_clients (const cmt_string& package,
53                              const cmt_string& version);
54  static void show_all (bool skip_discarded = false, ostream& out = cout, PrintMode mode = Csh); // Csh is default for ArgParser::mode
55  //  static void show_all (bool skip_discarded = false, ostream& out = cout );
56  //  static void show_all (bool skip_discarded = false);
57  static void show_all (const cmt_string& prefix, bool skip_discarded = false,
58                        ostream& out = cout, PrintMode mode = Csh); // Csh is default for ArgParser::mode
59  //  static void show_all (const cmt_string& prefix, bool skip_discarded = false);
60
61  static Use& current ();
62  static const Use& const_current ();
63
64  static UseVector& get_instances ();
65  static UsePtrVector& get_ordered_uses ();
66
67  static void clear_all ();
68  static void unselect_all ();
69  static void undiscard_all ();
70  static void fill_macro_all (cmt_string& buffer, const cmt_string& suffix);
71
72  static Use* create (const cmt_string& path,
73                      const cmt_string& package,
74                      const cmt_string& version,
75                      const cmt_string& version_alias,
76                      const cmt_string& path_alias,
77                      const cmt_string& n_version="");
78
79  void add_sub_use(Use* use) 
80  {
81      this->sub_uses.push_back (use);
82  }
83
84// Private class methods
85private:
86
87// Public instance methods
88public:
89  Use ();
90  Use (const cmt_string& new_package,
91       const cmt_string& new_version,
92       const cmt_string& new_path);
93  ~Use ();
94  void set (const cmt_string& new_package,
95            const cmt_string& new_version,
96            const cmt_string& new_path,
97            const cmt_string& new_version_alias = "",
98            const cmt_string& new_path_alias = "");
99  void author_action (const CmtSystem::cmt_string_vector& words);
100  void manager_action (const CmtSystem::cmt_string_vector& words);
101  bool move_to (const cmt_string& native_version="", bool curdir = false);
102  //  bool move_to (const cmt_string& native_version="");
103  void discard ();
104  void undiscard ();
105  void apply_global_patterns ();
106  void set_include_path (const cmt_string& new_path);
107  void get_full_path (cmt_string& s) const;
108  cmt_string get_full_path () const;
109  void reduce_path (cmt_string& s) const;
110  void get_cmtpath_and_offset (cmt_string& cmtpath, cmt_string& offset) const;
111  bool get_strategy (const cmt_string& name) const;
112
113  void fill_includes_macro (cmt_string& buffer) const;
114  void fill_macro (cmt_string& buffer, const cmt_string& suffix) const;
115  void fill_standard_macros (cmt_string& buffer) const;
116  void build_library_links (const cmt_string& cmtinstallarea, 
117                            const cmt_string& tag, 
118                            const cmt_string& shlibsuffix, 
119                            const cmt_string& symlinkcmd) const;
120  void remove_library_links (const cmt_string& cmtinstallarea, 
121                             const cmt_string& tag, 
122                             const cmt_string& shlibsuffix, 
123                             const cmt_string& symunlinkcmd) const;
124 
125  bool get_all_clients (const cmt_string& to_name);
126
127  bool get_paths (Use* to, UsePtrVector& list);
128
129  bool located () const;
130
131  void change_path (const cmt_string& path);
132  void set_auto_imports (State context_state, State specified_state,
133                         cmt_map <Use*, bool>& visited);
134  //  void set_auto_imports (State new_state);
135  //void set_auto_imports_state (cmt_vector<bool>& auto_imports_states,
136  //cmt_map <Use*, bool>& visited);
137  void set_native_version (bool state);
138  bool has_native_version () const;
139
140  Package* get_package () const;
141  const cmt_string& get_package_name () const;
142  void set_package_name (const cmt_string& name);
143
144  int get_index () const;
145
146  void show_cycles ();
147
148  void push_scope_section (ScopeType type);
149  void pop_scope_section ();
150  void close_scope_sections ();
151
152  ScopeType get_current_scope () const;
153
154  Project* get_project ();
155  cmt_string get_info () const;
156  bool is_head_version (const cmt_string& version);
157  void clear ();
158  void absolute_library_path (const cmt_string& libname,
159                              const cmt_string& shlibsuffix, 
160                              CmtSystem::cmt_string_vector& paths) const;
161// Public attributes
162public:
163
164  cmt_string specified_version;  /* idem                            */
165  cmt_string specified_path;     /* idem                            */
166  cmt_string version_alias;
167  cmt_string path_alias;
168  cmt_string author;             /* idem                            */
169  cmt_string manager;            /* idem                            */
170
171  cmt_string path;               /* expanded path                   */
172  cmt_string version;            /* idem                            */
173  cmt_string real_path;
174  cmt_string native_version;     /* idem                            */
175  CmtDirStyle style;             /* May be cmt, or mgr, or none_style */
176  CmtStructuringStyle structuring_style; /* with or without version directory */
177
178  cmt_string prefix;             /* upper case copy of package      */
179  bool done;                     /* true when requirements file has
180                                    already been read               */
181  bool discarded;                /* discarded by version strategy   */
182  bool selected;                 /* used for recursive access       */
183  bool m_located;
184  bool m_hidden;
185  ScopeType initial_scope;
186
187  UsePtrVector sub_uses;
188  cmt_vector<ScopeType> sub_use_scopes;
189  cmt_vector<State> sub_use_auto_imports;
190
191 int m_index;  // Position within the ordered list of uses
192 
193  State auto_imports;
194
195  Include::IncludeVector includes;
196  cmt_string include_path;
197  Script::ScriptVector scripts;
198  ApplyPattern::ApplyPatternVector apply_patterns;
199  IgnorePattern::IgnorePatternVector ignore_patterns;
200
201// Private methods
202private:
203  //  void clear ();
204  int reach_package (const cmt_string& current_path, const cmt_string& n_version="");
205  void select ();
206  void unselect ();
207  bool is_selected ();
208  bool is_client (const cmt_string& package,
209                  const cmt_string& version);
210  void show_sub_uses (cmt_map <Use*, bool>& visited,
211                      const cmt_string& request, State specified_state,
212                      bool skip_discarded = false, ostream& out = cout);
213  //  void show_sub_uses (const cmt_string& request, bool skip_discarded = false);
214  bool select_alternate ();
215  Use* get_selected_version ();
216  Use* set_selected_version (Use* selected_use);
217
218  static bool need_new (const cmt_string& path,
219                        const cmt_string& package,
220                        const cmt_string& version,
221                        const cmt_string& n_version,
222                        Use** old_use,
223                                    Use* context_use);
224
225  bool get_all_clients (Use* to, 
226                        const cmt_string& result, 
227                        cmt_map <cmt_string, Use*>& all_clients, 
228                        cmt_map <cmt_string, Use*>& all_clients_ok);
229
230// Private attributes
231private:
232
233  Package* m_package;
234  //cmt_string m_package_name; /* directly read from requirements */
235
236  bool m_has_native_version;
237
238
239  cmt_vector<ScopeSection> scope_sections;
240
241  CmtSystem::cmt_string_vector alternate_versions;
242  CmtSystem::cmt_string_vector alternate_paths;
243  cmt_vector<bool> alternate_is_head_versions;
244
245  CmtSystem::cmt_string_vector requests;
246
247  cmt_regexp m_head_version; 
248
249  friend class UseProjectAction;
250};
251
252class Package
253{
254public:
255
256  typedef cmt_map<cmt_string, Package> PackageMap;
257  typedef cmt_vector<Package> PackageVector;
258
259  static Package* find (const cmt_string& name);
260  static Package* add (const cmt_string& name);
261
262  static PackageVector& packages ();
263  static PackageMap& package_map ();
264
265  static void clear_all ();
266
267  static bool get_version (cmt_string& version, const cmt_string& path = ".");
268  static const cmt_string& get_version_file_name ();
269  static bool get_name (cmt_string& name, const cmt_string& path = ".");
270
271public:
272
273  Package ();
274  ~Package ();
275
276  const cmt_string& get_name () const;
277  void add_use (Use* use);
278  void remove_use (Use* use);
279  Use::UsePtrVector& get_uses ();
280
281  bool is_cmt ();
282
283private:
284  bool m_is_cmt;
285
286  cmt_string m_name;
287  Use::UsePtrVector m_uses;
288};
289
290#endif
Note: See TracBrowser for help on using the repository browser.