source: CMT/v1r23/source/cmt_use.h

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

See C.L. 457

  • Property svn:eol-style set to native
File size: 9.3 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
121  bool get_all_clients (const cmt_string& to_name);
122
123  bool get_paths (Use* to, UsePtrVector& list);
124
125  bool located () const;
126
127  void change_path (const cmt_string& path);
128  void set_auto_imports (State context_state, State specified_state,
129                         cmt_map <Use*, bool>& visited);
130  //  void set_auto_imports (State new_state);
131  //void set_auto_imports_state (cmt_vector<bool>& auto_imports_states,
132  //cmt_map <Use*, bool>& visited);
133  void set_native_version (bool state);
134  bool has_native_version () const;
135
136  Package* get_package () const;
137  const cmt_string& get_package_name () const;
138  void set_package_name (const cmt_string& name);
139
140  int get_index () const;
141
142  void show_cycles ();
143
144  void push_scope_section (ScopeType type);
145  void pop_scope_section ();
146  void close_scope_sections ();
147
148  ScopeType get_current_scope () const;
149
150  Project* get_project ();
151  cmt_string get_info () const;
152  bool is_head_version (const cmt_string& version);
153// Public attributes
154public:
155
156  cmt_string specified_version;  /* idem                            */
157  cmt_string specified_path;     /* idem                            */
158  cmt_string version_alias;
159  cmt_string path_alias;
160  cmt_string author;             /* idem                            */
161  cmt_string manager;            /* idem                            */
162
163  cmt_string path;               /* expanded path                   */
164  cmt_string version;            /* idem                            */
165  cmt_string real_path;
166  cmt_string native_version;     /* idem                            */
167  CmtDirStyle style;             /* May be cmt, or mgr, or none_style */
168  CmtStructuringStyle structuring_style; /* with or without version directory */
169
170  cmt_string prefix;             /* upper case copy of package      */
171  bool done;                     /* true when requirements file has
172                                    already been read               */
173  bool discarded;                /* discarded by version strategy   */
174  bool selected;                 /* used for recursive access       */
175  bool m_located;
176  bool m_hidden;
177  ScopeType initial_scope;
178
179  UsePtrVector sub_uses;
180  cmt_vector<ScopeType> sub_use_scopes;
181  cmt_vector<State> sub_use_auto_imports;
182
183 int m_index;  // Position within the ordered list of uses
184 
185  State auto_imports;
186
187  Include::IncludeVector includes;
188  cmt_string include_path;
189  Script::ScriptVector scripts;
190  ApplyPattern::ApplyPatternVector apply_patterns;
191  IgnorePattern::IgnorePatternVector ignore_patterns;
192
193// Private methods
194private:
195  void clear ();
196  int reach_package (const cmt_string& current_path, const cmt_string& n_version="");
197  void select ();
198  void unselect ();
199  bool is_selected ();
200  bool is_client (const cmt_string& package,
201                  const cmt_string& version);
202  void show_sub_uses (cmt_map <Use*, bool>& visited,
203                      const cmt_string& request, State specified_state,
204                      bool skip_discarded = false, ostream& out = cout);
205  //  void show_sub_uses (const cmt_string& request, bool skip_discarded = false);
206  bool select_alternate ();
207  Use* get_selected_version ();
208  Use* set_selected_version (Use* selected_use);
209
210  static bool need_new (const cmt_string& path,
211                        const cmt_string& package,
212                        const cmt_string& version,
213                        const cmt_string& n_version,
214                        Use** old_use,
215                                    Use* context_use);
216
217  bool get_all_clients (Use* to, 
218                        const cmt_string& result, 
219                        cmt_map <cmt_string, Use*>& all_clients, 
220                        cmt_map <cmt_string, Use*>& all_clients_ok);
221
222// Private attributes
223private:
224
225  Package* m_package;
226  //cmt_string m_package_name; /* directly read from requirements */
227
228  bool m_has_native_version;
229
230
231  cmt_vector<ScopeSection> scope_sections;
232
233  CmtSystem::cmt_string_vector alternate_versions;
234  CmtSystem::cmt_string_vector alternate_paths;
235  cmt_vector<bool> alternate_is_head_versions;
236
237  CmtSystem::cmt_string_vector requests;
238
239  cmt_regexp m_head_version; 
240
241  friend class UseProjectAction;
242};
243
244class Package
245{
246public:
247
248  typedef cmt_map<cmt_string, Package> PackageMap;
249  typedef cmt_vector<Package> PackageVector;
250
251  static Package* find (const cmt_string& name);
252  static Package* add (const cmt_string& name);
253
254  static PackageVector& packages ();
255  static PackageMap& package_map ();
256
257  static void clear_all ();
258
259  static bool get_version (cmt_string& version, const cmt_string& path = ".");
260  static const cmt_string& get_version_file_name ();
261  static bool get_name (cmt_string& name, const cmt_string& path = ".");
262
263public:
264
265  Package ();
266  ~Package ();
267
268  const cmt_string& get_name () const;
269  void add_use (Use* use);
270  void remove_use (Use* use);
271  Use::UsePtrVector& get_uses ();
272
273  bool is_cmt ();
274
275private:
276  bool m_is_cmt;
277
278  cmt_string m_name;
279  Use::UsePtrVector m_uses;
280};
281
282#endif
Note: See TracBrowser for help on using the repository browser.