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

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

See C.L. 422

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