source: CMT/v1r20p20070517/source/cmt_use.h

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

fixed bug with the hidden type package

  • Property svn:eol-style set to native
File size: 7.8 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// Public attributes
137public:
138
139  cmt_string specified_version;  /* idem                            */
140  cmt_string specified_path;     /* idem                            */
141  cmt_string version_alias;
142  cmt_string path_alias;
143  cmt_string author;             /* idem                            */
144  cmt_string manager;            /* idem                            */
145
146  cmt_string path;               /* expanded path                   */
147  cmt_string version;            /* idem                            */
148  cmt_string real_path;
149  cmt_string native_version;     /* idem                            */
150  CmtDirStyle style;             /* May be cmt or mgr               */
151
152  cmt_string prefix;             /* upper case copy of package      */
153  bool done;                     /* true when requirements file has
154                                    already been read               */
155  bool discarded;                /* discarded by version strategy   */
156  bool selected;                 /* used for recursive access       */
157  bool m_located;
158  bool m_hidden;
159  ScopeType initial_scope;
160
161  UsePtrVector sub_uses;
162  cmt_vector<ScopeType> sub_use_scopes;
163  cmt_vector<State> sub_use_auto_imports;
164
165 int m_index;  // Position within the ordered list of uses
166 
167  State auto_imports;
168
169  Include::IncludeVector includes;
170  cmt_string include_path;
171  Script::ScriptVector scripts;
172  ApplyPattern::ApplyPatternVector apply_patterns;
173  IgnorePattern::IgnorePatternVector ignore_patterns;
174
175// Private methods
176private:
177  void clear ();
178  int reach_package (const cmt_string& current_path, const cmt_string& n_version="");
179  void select ();
180  void unselect ();
181  bool is_selected ();
182  bool is_client (const cmt_string& package,
183                  const cmt_string& version);
184  void show_sub_uses (const cmt_string& request, bool skip_discarded = false);
185  bool select_alternate ();
186  Use* get_selected_version ();
187  Use* set_selected_version (Use* selected_use);
188
189  static bool need_new (const cmt_string& path,
190                        const cmt_string& package,
191                        const cmt_string& version,
192                        const cmt_string& n_version,
193                        Use** old_use,
194                                    Use* context_use);
195
196  bool get_all_clients (Use* to, 
197                        const cmt_string& result, 
198                        cmt_map <cmt_string, Use*>& all_clients, 
199                        cmt_map <cmt_string, Use*>& all_clients_ok);
200
201// Private attributes
202private:
203
204  Package* m_package;
205  //cmt_string m_package_name; /* directly read from requirements */
206
207  bool m_has_native_version;
208
209
210  cmt_vector<ScopeSection> scope_sections;
211
212  CmtSystem::cmt_string_vector alternate_versions;
213  CmtSystem::cmt_string_vector alternate_paths;
214
215  CmtSystem::cmt_string_vector requests;
216
217 
218
219  friend class UseProjectAction;
220};
221
222class Package
223{
224public:
225
226  typedef cmt_map<cmt_string, Package> PackageMap;
227  typedef cmt_vector<Package> PackageVector;
228
229  static Package* find (const cmt_string& name);
230  static Package* add (const cmt_string& name);
231
232  static PackageVector& packages ();
233  static PackageMap& package_map ();
234
235  static void clear_all ();
236
237public:
238
239  Package ();
240  ~Package ();
241
242  const cmt_string& get_name () const;
243  void add_use (Use* use);
244  void remove_use (Use* use);
245  Use::UsePtrVector& get_uses ();
246
247  bool is_cmt ();
248
249private:
250  bool m_is_cmt;
251
252  cmt_string m_name;
253  Use::UsePtrVector m_uses;
254};
255
256#endif
Note: See TracBrowser for help on using the repository browser.