source: CMT/v1r20p20090520/source/cmt_project.h

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

See C.L. 377

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