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

Last change on this file since 526 was 526, checked in by rybkin, 15 years ago

See C.L. 413

  • Property svn:eol-style set to native
File size: 6.9 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 clear_all ();
113  static void show_all ();
114  static void show_container ();
115  static void show_specified_strategies_for_all ();
116  static void show_paths (const CmtSystem::cmt_string_vector& arguments);
117  //  static void show_paths ();
118  static const cmt_string& get_project_file_name ();
119
120  static void fill_selection (int depth, CmtSystem::cmt_string_vector& path_selections);
121
122  static void broadcast (IProjectAction& action);
123  static void reverse_broadcast (IProjectAction& action);
124  static void scan_paths (PathScanner& scanner, PathScanner::actor& actor);
125  static void scan_paths_for_package (PathScanner& scanner, const cmt_string& name);
126
127  static cmt_string find_in_cmt_paths (const cmt_string& path);
128
129  static void fill_cmtpaths (cmt_string& buffer);
130
131  static void start_visit (IProjectVisitor& visitor);
132
133public:
134
135  Project ();
136
137  const cmt_string& get_name () const;
138  const cmt_string& get_release () const;
139  const cmt_string& get_container_name () const;
140  const cmt_string& get_container_version () const;
141  const cmt_string& get_container_path () const;
142  const Use& get_container () const;
143  const cmt_string& get_cmtpath () const;
144  const cmt_string& get_cmtpath_real () const;
145  const cmt_string& get_cmtpath_pwd () const;
146  const cmt_string& get_cmtpath_source () const;
147  int get_children_size () const;
148 
149  const CmtSystem::cmt_string_vector get_project_releases(const cmt_string& name) const; 
150  bool select_release(const cmt_string& name, const cmt_string& release, cmt_string& result);
151 
152  Project* get_child (int index) const;
153  bool visited () const;
154
155  void set_name (const cmt_string& name);
156  void set_release (const cmt_string& release);
157  //  void set_container (const cmt_string& container);
158  void set_container_name (const cmt_string& name);
159  void set_container_version (const cmt_string& version);
160  void set_container_path (const cmt_string& path);
161  void set_cmtpath (const cmt_string& path);
162  void set_cmtpath_real (const cmt_string& path);
163  void set_cmtpath_pwd (const cmt_string& path);
164  void set_cmtpath_source (const cmt_string& source);
165  void clear ();
166  void configure ();
167  bool has_parents () const;
168  bool has_parent (Project* p) const;
169  bool has_child (Project* p) const;
170  void add_parent (Project* p);
171  void add_child (Project* p);
172
173  void container_action (const CmtSystem::cmt_string_vector& words);
174  //  void container_action (const cmt_string& name, const cmt_string& version);
175  void use_action (const cmt_string& name, const cmt_string& release);
176
177  Project& operator = (const Project& other);
178  bool operator == (const cmt_string& name) const;
179  bool operator != (const cmt_string& name) const;
180
181  void show ();
182  void show_specified_strategies () const;
183
184  bool has_strategy (const StrategyDef* definition) const;
185  bool is_specified (const StrategyDef* definition) const;
186  bool get_strategy (const StrategyDef* definition) const;
187  bool get_strategy (const cmt_string& name) const;
188  void set_default_strategy (const cmt_string& name);
189  void set_strategy (const cmt_string& name, const cmt_string& value, const cmt_string& context);
190  void set_strategy (StrategyDef* definition, bool b_value, const cmt_string& context);
191  void update_strategy (StrategyDef* definition, bool b_value);
192  void update_strategy_from_children (StrategyDef* definition);
193  void update_strategies_from_children ();
194  void set_author (const cmt_string& name);
195  const cmt_string& get_author () const;
196  void project_author_action (const CmtSystem::cmt_string_vector& words);
197  // bool get_author (const cmt_string& name) const;
198 
199  void   visit (IProjectVisitor& visitor);
200  static  void   visit (IProjectVisitor& visitor, ProjectPtrVector& projects);
201  static  void   visit (const int offset, int& order, ProjectPtrVector& projects);
202 
203  // Use
204  Use*  get_use () const; 
205  void  set_use (Use* use); 
206 
207  cmt_vector <cmt_string> m_extra_lines;
208 
209private:
210
211  void fill_cmtpath (cmt_string& buffer);
212
213  cmt_string m_name;
214  cmt_string m_author;
215  cmt_string m_release;
216  cmt_string m_container_name;
217  cmt_string m_container_version;
218  cmt_string m_container_path;
219  Use m_container;
220
221  ProjectPtrVector m_parents;
222  ProjectPtrVector m_children;
223
224  bool m_visited;
225  int m_visits;
226  int m_order;
227
228  cmt_string m_cmtpath;
229  cmt_string m_cmtpath_real;
230  cmt_string m_cmtpath_pwd;
231  cmt_string m_cmtpath_source;
232
233  bool m_configured;
234
235  cmt_vector <Strategy> m_strategies;
236 
237  Use* m_use;
238};
239
240
241#endif
Note: See TracBrowser for help on using the repository browser.