source: CMT/HEAD/source/cmt_project.h @ 581

Last change on this file since 581 was 581, checked in by rybkin, 13 years ago

See C.L. 459

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