source: CMT/v1r21/source/cmt_use.h @ 654

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

See C.L. 423

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