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

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

See C.L. 446

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