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

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

See C.L. 459

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