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

Last change on this file since 471 was 471, checked in by rybkin, 16 years ago

See C.L. 372

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