source: CMT/v1r18p20060606/source/cmt_project.h

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

Fixing session - see CL#275

  • Property svn:eol-style set to native
File size: 5.5 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 bool 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_container () const;
134  const cmt_string& get_container_version () const;
135  const cmt_string& get_cmtpath () const;
136  const cmt_string& get_cmtpath_pwd () const;
137  const cmt_string& get_cmtpath_source () const;
138  int get_children_size () const;
139  Project* get_child (int index) const;
140  bool visited () const;
141
142  void set_name (const cmt_string& name);
143  void set_release (const cmt_string& release);
144  void set_container (const cmt_string& container);
145  void set_container_version (const cmt_string& version);
146  void set_cmtpath (const cmt_string& path);
147  void set_cmtpath_pwd (const cmt_string& path);
148  void set_cmtpath_source (const cmt_string& source);
149  void clear ();
150  void configure ();
151  bool has_parents () const;
152  bool has_parent (Project* p) const;
153  bool has_child (Project* p) const;
154  void add_parent (Project* p);
155  void add_child (Project* p);
156
157  void container_action (const cmt_string& name, const cmt_string& version);
158  void use_action (const cmt_string& name, const cmt_string& release);
159
160  Project& operator = (const Project& other);
161  bool operator == (const cmt_string& name) const;
162  bool operator != (const cmt_string& name) const;
163
164  void show ();
165  void show_specified_strategies () const;
166
167  bool has_strategy (const StrategyDef* definition) const;
168  bool is_specified (const StrategyDef* definition) const;
169  bool get_strategy (const StrategyDef* definition) const;
170  bool get_strategy (const cmt_string& name) const;
171  void set_default_strategy (const cmt_string& name);
172  void set_strategy (const cmt_string& name, const cmt_string& value, const cmt_string& context);
173  void set_strategy (StrategyDef* definition, bool b_value, const cmt_string& context);
174  void update_strategy (StrategyDef* definition, bool b_value);
175  void update_strategy_from_children (StrategyDef* definition);
176  void update_strategies_from_children ();
177
178  void visit (IProjectVisitor& visitor);
179
180private:
181
182  void fill_cmtpath (cmt_string& buffer);
183
184  cmt_string m_name;
185  cmt_string m_release;
186  cmt_string m_container;
187  cmt_string m_container_version;
188
189  ProjectPtrVector m_parents;
190  ProjectPtrVector m_children;
191
192  bool m_visited;
193
194  cmt_string m_cmtpath;
195  cmt_string m_cmtpath_pwd;
196  cmt_string m_cmtpath_source;
197
198  bool m_configured;
199
200  cmt_vector <Strategy> m_strategies;
201};
202
203
204#endif
Note: See TracBrowser for help on using the repository browser.