source: CMT/HEAD/source/cmt_project.h

Last change on this file was 663, checked in by rybkin, 10 years ago

See C.L. 522

  • 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// Modified by Grigory Rybkin
6// See the complete license in cmt_license.txt "http://www.cecill.info".
7//-----------------------------------------------------------
8
9#ifndef __cmt_project_h__
10#define __cmt_project_h__
11
12#include "cmt_parser.h"
13#include "cmt_system.h"
14#include "cmt_use.h"
15#include "cmt_awk.h"
16
17class Project;
18
19class StrategyDef
20{
21public:
22  typedef cmt_vector <StrategyDef*> StrategyDefs;
23
24  cmt_string m_keyword;
25  cmt_string m_name;
26  cmt_string m_on_value;
27  cmt_string m_off_value;
28  bool m_default_value;
29  bool m_priority_value;
30
31  const cmt_string& get_default_value () const; 
32};
33
34class Strategy
35{
36public:
37  StrategyDef* m_definition;
38  bool m_specified;
39  bool m_specified_value;
40  bool m_value;
41  Tag* m_on_tag;
42  Tag* m_off_tag;
43  cmt_string m_context;
44
45  Strategy ();
46  void clear ();
47  void set (StrategyDef* definition, bool value, const cmt_string& project_name);
48  void update (StrategyDef* definition, bool value, const cmt_string& project_name);
49};
50
51class StrategyMgr
52{
53public:
54  static StrategyMgr& instance ();
55  static StrategyDef* find_strategy (const cmt_string& name);
56  static bool get_default_strategy (const cmt_string& name);
57  static bool get_priority_strategy (const cmt_string& name);
58  static StrategyDef::StrategyDefs& get_definitions ();
59
60private:
61  StrategyMgr ();
62  StrategyDef::StrategyDefs m_defs;
63};
64
65class ProjectFactory : public IProjectFactory
66{
67public:
68  static IProjectFactory& instance ();
69
70public:
71  void reset ();
72  Project* create_project (const cmt_string& name,
73                           const cmt_string& path,
74                           const cmt_string& path_source,
75                           Project* parent);
76
77};
78
79class IProjectAction
80{
81public:
82  virtual bool run (const Project& project) = 0;
83};
84
85class IProjectVisitor
86{
87public:
88  virtual void pre (Project* p) = 0;
89  virtual void in (Project* p) = 0;
90  virtual void in_again (Project* p) = 0;
91  virtual void post (Project* p) = 0;
92};
93
94class Project
95{
96public:
97
98  typedef cmt_vector<Project> ProjectVector;
99  typedef cmt_vector<Project*> ProjectPtrVector;
100  typedef cmt_vector<const Project*> ConstProjectPtrVector;
101
102  static bool create (const cmt_string& name, 
103                      const cmt_string& release, 
104                      const cmt_string& path);
105
106  static Project* find_by_name (const cmt_string& name);
107  static Project* find_by_cmtpath (const cmt_string& cmtpath);
108  static Project* get_current ();
109  static Project* add (const cmt_string& name,
110                       const cmt_string& release);
111
112  static ProjectVector& projects ();
113  static ProjectPtrVector& ordered_projects ();
114  static void order_all ();
115  static void clear_all ();
116  static void show_all (PrintMode mode = Csh); // Csh is default for ArgParser::mode
117  //  static void show_all ();
118  static void show_container (const cmt_string& path = "");
119  static void show_specified_strategies_for_all ();
120  static void show_paths (const CmtSystem::cmt_string_vector& arguments, ostream& out = cout);
121  //  static void show_paths ();
122  static const cmt_string& get_project_file_name ();
123
124  static void fill_selection (int depth, ConstProjectPtrVector& path_selections);
125  //  static void fill_selection (int depth, CmtSystem::cmt_string_vector& path_selections);
126  static void fill_exclusion (ConstProjectPtrVector& path_exclusions);
127
128  static void broadcast (IProjectAction& action);
129  static void reverse_broadcast (IProjectAction& action);
130  static void scan_paths (PathScanner& scanner, PathScanner::actor& actor);
131  static void scan_paths_for_package (PathScanner& scanner, const cmt_string& name);
132
133  static cmt_string find_in_cmt_paths (const cmt_string& path, bool realpath = false);
134
135  static void fill_cmtpaths (cmt_string& buffer);
136
137  static void start_visit (IProjectVisitor& visitor);
138
139public:
140
141  Project ();
142
143  const cmt_string& get_name () const;
144  const cmt_string& get_release () const;
145  const cmt_string& get_container_name () const;
146  const cmt_string& get_container_version () const;
147  const cmt_string& get_container_path () const;
148  const Use& get_container () const;
149  const cmt_string& get_cmtpath () const;
150  const cmt_string& get_cmtpath_real () const;
151  const cmt_string& get_cmtpath_pwd () const;
152  const cmt_string& get_cmtpath_source () const;
153  int get_children_size () const;
154 
155  const CmtSystem::cmt_string_vector get_project_releases(const cmt_string& name) const; 
156  bool select_release(const cmt_string& name, const cmt_string& release, cmt_string& result);
157 
158  Project* get_child (int index) const;
159  bool visited () const;
160
161  void set_name (const cmt_string& name);
162  void set_release (const cmt_string& release);
163  //  void set_container (const cmt_string& container);
164  void set_container_name (const cmt_string& name);
165  void set_container_version (const cmt_string& version);
166  void set_container_path (const cmt_string& path);
167  void set_cmtpath (const cmt_string& path);
168  void set_cmtpath_real (const cmt_string& path);
169  void set_cmtpath_pwd (const cmt_string& path);
170  void set_cmtpath_source (const cmt_string& source);
171  void set_is_current (bool is_current);
172  bool is_current () const;
173  void clear ();
174  void configure ();
175  bool has_parents () const;
176  bool has_parent (Project* p) const;
177  bool has_child (Project* p) const;
178  void add_parent (Project* p);
179  void add_child (Project* p);
180  void erase_child (Project* p);
181
182  void container_action (const CmtSystem::cmt_string_vector& words);
183  //  void container_action (const cmt_string& name, const cmt_string& version);
184  void use_action (const cmt_string& name, const cmt_string& release);
185
186  //  Project& operator = (const Project& other);
187  bool operator == (const cmt_string& name) const;
188  bool operator != (const cmt_string& name) const;
189
190  void show (PrintMode mode = Csh); // Csh is default for ArgParser::mode
191  //  void show ();
192  void show_specified_strategies () const;
193
194  bool has_strategy (const StrategyDef* definition) const;
195  bool is_specified (const StrategyDef* definition) const;
196  bool get_strategy (const StrategyDef* definition) const;
197  bool get_strategy (const cmt_string& name) const;
198  void set_default_strategy (const cmt_string& name);
199  void set_strategy (const cmt_string& name, const cmt_string& value, const cmt_string& context);
200  void set_strategy (StrategyDef* definition, bool b_value, const cmt_string& context);
201  void update_strategy (StrategyDef* definition, bool b_value);
202  void update_strategy_from_children (StrategyDef* definition);
203  void update_strategies_from_children ();
204  void set_author (const cmt_string& name);
205  const cmt_string& get_author () const;
206  void project_author_action (const CmtSystem::cmt_string_vector& words);
207  // bool get_author (const cmt_string& name) const;
208 
209  void   visit (IProjectVisitor& visitor);
210  static  void   visit (IProjectVisitor& visitor, ProjectPtrVector& projects);
211  static  void   visit (const int offset, int& order, ProjectPtrVector& projects);
212 
213  // Use
214  Use*  get_use () const; 
215  void  set_use (Use* use); 
216 
217  cmt_vector <cmt_string> m_extra_lines;
218 
219private:
220
221  Project& operator = (const Project& other);
222  Project (const Project& other);
223
224  void fill_cmtpath (cmt_string& buffer);
225
226  cmt_string m_name;
227  cmt_string m_author;
228  cmt_string m_release;
229  cmt_string m_container_name;
230  cmt_string m_container_version;
231  cmt_string m_container_path;
232  Use m_container;
233
234  ProjectPtrVector m_parents;
235  ProjectPtrVector m_children;
236
237  bool m_visited;
238  int m_visits;
239  int m_order;
240  bool m_is_current;
241
242  cmt_string m_cmtpath;
243  cmt_string m_cmtpath_real;
244  cmt_string m_cmtpath_pwd;
245  cmt_string m_cmtpath_source;
246
247  bool m_configured;
248
249  cmt_vector <Strategy> m_strategies;
250 
251  Use* m_use;
252};
253
254
255#endif
Note: See TracBrowser for help on using the repository browser.