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

Last change on this file since 272 was 272, checked in by garonne, 18 years ago

See CL 313

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