source: CMT/v1r25-branch/source/cmt_use.h

Last change on this file was 664, checked in by rybkin, 10 years ago

merge -r 646:663 HEAD

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