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

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

See C.L. 455

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