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

Last change on this file since 283 was 283, checked in by arnault, 18 years ago

New keyword cmtpath_pattern_revert - See CL 318

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