source: CMT/v1r14p20031120/src/cmt_use.h @ 1

Last change on this file since 1 was 1, checked in by arnault, 19 years ago

Import all tags

File size: 6.8 KB
Line 
1#ifndef __cmt_use_h__
2#define __cmt_use_h__
3
4#include "cmt_map.h"
5#include "cmt_include.h"
6#include "cmt_script.h"
7#include "cmt_pattern.h"
8
9class Project;
10
11class Package;
12
13class Use
14{
15// Public class methods
16public:
17  typedef cmt_vector<Use> UseVector;
18  typedef cmt_vector<Use*> UsePtrVector;
19
20  static Use* action (const CmtSystem::cmt_string_vector& words, Use* use);
21  static Use* find (const cmt_string& package,
22                    const cmt_string& version = "",
23                    const cmt_string& path = "");
24  static int find_index (const cmt_string& package, 
25                         const cmt_string& version, 
26                         const cmt_string& path);
27  static void set_auto_imports_state (int use_index,
28                                      cmt_vector<bool>& auto_imports_states);
29  static Use* add (const cmt_string& path,
30                   const cmt_string& package,
31                   const cmt_string& version,
32                   const cmt_string& version_alias,
33                   const cmt_string& path_alias,
34                   Use* context_use,
35                   State specified_auto_imports = Unspecified);
36  static void move (Use* use1);
37  static void reorder (Use* use1, Use* use2);
38  static void select_clients (const cmt_string& package,
39                              const cmt_string& version);
40  static void show_all (bool skip_discarded = false);
41  static void show_all (const cmt_string& prefix, bool skip_discarded = false);
42
43  static Use& current ();
44  static const Use& const_current ();
45
46  static UseVector& get_instances ();
47  static UsePtrVector& get_ordered_uses ();
48
49  static void clear_all ();
50  static void unselect_all ();
51  static void undiscard_all ();
52  static void fill_macro_all (cmt_string& buffer, const cmt_string& suffix);
53
54// Private class methods
55private:
56  static Use* create (const cmt_string& path,
57                      const cmt_string& package,
58                      const cmt_string& version,
59                      const cmt_string& version_alias,
60                      const cmt_string& path_alias);
61
62// Public instance methods
63public:
64  Use ();
65  Use (const cmt_string& new_package,
66       const cmt_string& new_version,
67       const cmt_string& new_path);
68  ~Use ();
69  void set (const cmt_string& new_package,
70            const cmt_string& new_version,
71            const cmt_string& new_path,
72            const cmt_string& new_version_alias = "",
73            const cmt_string& new_path_alias = "");
74  void author_action (const CmtSystem::cmt_string_vector& words);
75  void manager_action (const CmtSystem::cmt_string_vector& words);
76  bool move_to ();
77  void discard ();
78  void undiscard ();
79  void apply_global_patterns ();
80  void set_include_path (const cmt_string& new_path);
81  void get_full_path (cmt_string& s) const;
82  cmt_string get_full_path () const;
83  void reduce_path (cmt_string& s) const;
84
85  void fill_includes_macro (cmt_string& buffer) const;
86  void fill_macro (cmt_string& buffer, const cmt_string& suffix) const;
87
88  bool get_all_clients (const cmt_string& to_name);
89
90  bool get_paths (Use* to, UsePtrVector& list);
91
92  bool located () const;
93
94  void change_path (const cmt_string& path);
95  void set_auto_imports (State new_state);
96  void set_native_version (bool state);
97  bool has_native_version () const;
98
99  void set_project (Project* project);
100
101  Package* get_package () const;
102  const cmt_string& get_package_name () const;
103  void set_package_name (const cmt_string& name);
104
105  int get_index () const;
106
107  void show_cycles ();
108
109// Public attributes
110public:
111
112  cmt_string specified_version;  /* idem                            */
113  cmt_string specified_path;     /* idem                            */
114  cmt_string version_alias;
115  cmt_string path_alias;
116  cmt_string author;             /* idem                            */
117  cmt_string manager;            /* idem                            */
118
119  cmt_string path;               /* expanded path                   */
120  cmt_string version;            /* idem                            */
121  cmt_string real_path;
122  CmtDirStyle style;             /* May be cmt or mgr               */
123
124  cmt_string prefix;             /* upper case copy of package      */
125  ScopeType scope;               /* copy of the current scope       */
126  bool done;                     /* true when requirements file has
127                                    already been read               */
128  bool discarded;                /* discarded by version strategy   */
129  bool selected;                 /* used for recursive access       */
130
131  State auto_imports;
132
133  Include::IncludeVector includes;
134  cmt_string include_path;
135  Script::ScriptVector scripts;
136  ApplyPattern::ApplyPatternVector apply_patterns;
137  IgnorePattern::IgnorePatternVector ignore_patterns;
138
139// Private methods
140private:
141  void clear ();
142  int reach_package (const cmt_string& current_path);
143  void select ();
144  void unselect ();
145  bool is_selected ();
146  bool is_client (const cmt_string& package,
147                  const cmt_string& version);
148  void show_sub_uses (const cmt_string& request, bool skip_discarded = false);
149  bool select_alternate ();
150  Use* get_selected_version ();
151  Use* set_selected_version (Use* selected_use);
152
153  static bool need_new (const cmt_string& path,
154                        const cmt_string& package,
155                        const cmt_string& version,
156                        Use** old_use,
157                        Use* context_use);
158
159  bool get_all_clients (Use* to, 
160                        const cmt_string& result, 
161                        cmt_map <cmt_string, Use*>& all_clients, 
162                        cmt_map <cmt_string, Use*>& all_clients_ok);
163
164// Private attributes
165private:
166
167  Package* m_package;
168  //cmt_string m_package_name; /* directly read from requirements */
169
170  bool m_located;
171  bool m_has_native_version;
172
173  UsePtrVector sub_uses;
174  cmt_vector<ScopeType> sub_use_scopes;
175  cmt_vector<State> sub_use_auto_imports;
176
177  CmtSystem::cmt_string_vector alternate_versions;
178  CmtSystem::cmt_string_vector alternate_paths;
179
180  CmtSystem::cmt_string_vector requests;
181
182  Project* m_project;
183
184  int m_index;  // Position within the ordered list of uses
185};
186
187class Package
188{
189public:
190
191  typedef cmt_map<cmt_string, Package> PackageMap;
192  typedef cmt_vector<Package> PackageVector;
193
194  static Package* find (const cmt_string& name);
195  static Package* add (const cmt_string& name);
196
197  static PackageVector& packages ();
198  static PackageMap& package_map ();
199
200  static void clear_all ();
201
202public:
203
204  Package ();
205  ~Package ();
206
207  const cmt_string& get_name () const;
208  void add_use (Use* use);
209  void remove_use (Use* use);
210  Use::UsePtrVector& get_uses ();
211
212  bool is_cmt ();
213
214private:
215  bool m_is_cmt;
216
217  cmt_string m_name;
218  Use::UsePtrVector m_uses;
219};
220
221#endif
Note: See TracBrowser for help on using the repository browser.