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

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

See C.L. 432

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