source: CMT/v1r19p20061115/source/cmt_use.h

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

beta development 1

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