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

Last change on this file since 36 was 36, checked in by arnault, 19 years ago

Fix bug in project hierarchy. See CL 265

  • Property svn:eol-style set to native
File size: 5.1 KB
Line 
1//-----------------------------------------------------------
2// Copyright Christian Arnault LAL-Orsay CNRS
3// arnault@lal.in2p3.fr
4// See the complete license in cmt_license.txt "http://www.cecill.info".
5//-----------------------------------------------------------
6
7#ifndef __cmt_project_h__
8#define __cmt_project_h__
9
10#include "cmt_parser.h"
11#include "cmt_system.h"
12#include "cmt_awk.h"
13
14class Project;
15
16class StrategyDef
17{
18public:
19  typedef cmt_vector <StrategyDef*> StrategyDefs;
20
21  cmt_string m_keyword;
22  cmt_string m_name;
23  cmt_string m_on_value;
24  cmt_string m_off_value;
25  bool m_default_value;
26  bool m_priority_value;
27
28  const cmt_string& get_default_value () const; 
29};
30
31class Strategy
32{
33public:
34  StrategyDef* m_definition;
35  bool m_specified;
36  bool m_specified_value;
37  bool m_value;
38  Tag* m_on_tag;
39  Tag* m_off_tag;
40  cmt_string m_context;
41
42  Strategy ();
43  void clear ();
44  void set (StrategyDef* definition, bool value, const cmt_string& project_name);
45  void update (StrategyDef* definition, bool value, const cmt_string& project_name);
46};
47
48class StrategyMgr
49{
50public:
51  static StrategyMgr& instance ();
52  static StrategyDef* find_strategy (const cmt_string& name);
53  static bool get_default_strategy (const cmt_string& name);
54  static bool get_priority_strategy (const cmt_string& name);
55  static StrategyDef::StrategyDefs& get_definitions ();
56
57private:
58  StrategyMgr ();
59  StrategyDef::StrategyDefs m_defs;
60};
61
62class ProjectFactory : public IProjectFactory
63{
64public:
65  static IProjectFactory& instance ();
66
67public:
68  void reset ();
69  Project* create_project (const cmt_string& name,
70                           const cmt_string& path,
71                           const cmt_string& path_source,
72                           Project* parent);
73
74};
75
76class IProjectAction
77{
78public:
79  virtual bool run (const Project& project) = 0;
80};
81
82class IProjectVisitor
83{
84public:
85  virtual void pre (Project* p) = 0;
86  virtual void in (Project* p) = 0;
87  virtual void post (Project* p) = 0;
88};
89
90class Project
91{
92public:
93
94  typedef cmt_vector<Project> ProjectVector;
95  typedef cmt_vector<Project*> ProjectPtrVector;
96
97  static void create (const cmt_string& name, 
98                      const cmt_string& release, 
99                      const cmt_string& path);
100
101  static Project* find_by_name (const cmt_string& name);
102  static Project* find_by_cmtpath (const cmt_string& cmtpath);
103  static Project* get_current ();
104  static Project* add (const cmt_string& name,
105                       const cmt_string& release);
106
107  static ProjectVector& projects ();
108  static void clear_all ();
109  static void show_all ();
110  static void show_specified_strategies_for_all ();
111  static void show_paths ();
112  static const cmt_string& get_project_file_name ();
113
114  static void fill_selection (int depth, CmtSystem::cmt_string_vector& path_selections);
115
116  static void broadcast (IProjectAction& action);
117  static void reverse_broadcast (IProjectAction& action);
118  static void scan_paths (PathScanner& scanner, PathScanner::actor& actor);
119  static void scan_paths_for_package (PathScanner& scanner, const cmt_string& name);
120
121  static cmt_string find_in_cmt_paths (const cmt_string& path);
122
123  static void fill_cmtpaths (cmt_string& buffer);
124
125  static void start_visit (IProjectVisitor& visitor);
126
127public:
128
129  Project ();
130
131  const cmt_string& get_name () const;
132  const cmt_string& get_release () const;
133  const cmt_string& get_cmtpath () const;
134  const cmt_string& get_cmtpath_pwd () const;
135  const cmt_string& get_cmtpath_source () const;
136  int get_children_size () const;
137  Project* get_child (int index) const;
138  bool visited () const;
139
140  void set_name (const cmt_string& name);
141  void set_release (const cmt_string& release);
142  void set_cmtpath (const cmt_string& path);
143  void set_cmtpath_pwd (const cmt_string& path);
144  void set_cmtpath_source (const cmt_string& source);
145  void clear ();
146  void configure ();
147  bool has_parent (Project* p) const;
148  bool has_child (Project* p) const;
149  void add_parent (Project* p);
150  void add_child (Project* p);
151
152  void use_action (const cmt_string& name, const cmt_string& release);
153
154  Project& operator = (const Project& other);
155  bool operator == (const cmt_string& name) const;
156  bool operator != (const cmt_string& name) const;
157
158  void show ();
159  void show_specified_strategies () const;
160
161  bool has_strategy (const StrategyDef* definition) const;
162  bool is_specified (const StrategyDef* definition) const;
163  bool get_strategy (const StrategyDef* definition) const;
164  bool get_strategy (const cmt_string& name) const;
165  void set_default_strategy (const cmt_string& name);
166  void set_strategy (const cmt_string& name, const cmt_string& value, const cmt_string& context);
167  void set_strategy (StrategyDef* definition, bool b_value, const cmt_string& context);
168  void update_strategy (StrategyDef* definition, bool b_value);
169  void update_strategy_from_children (StrategyDef* definition);
170  void update_strategies_from_children ();
171
172  void visit (IProjectVisitor& visitor);
173
174private:
175
176  void fill_cmtpath (cmt_string& buffer);
177
178  cmt_string m_name;
179  cmt_string m_release;
180
181  ProjectPtrVector m_parents;
182  ProjectPtrVector m_children;
183
184  bool m_visited;
185
186  cmt_string m_cmtpath;
187  cmt_string m_cmtpath_pwd;
188  cmt_string m_cmtpath_source;
189
190  bool m_configured;
191
192  cmt_vector <Strategy> m_strategies;
193};
194
195
196#endif
Note: See TracBrowser for help on using the repository browser.