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

Last change on this file since 550 was 550, checked in by rybkin, 14 years ago

See C.L. 435

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