multovl  1.3
Multiple overlaps of genomic regions
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
basepipeline.hh
1 /* <LICENSE>
2 License for the MULTOVL multiple genomic overlap tools
3 
4 Copyright (c) 2007-2012, Dr Andras Aszodi,
5 Campus Science Support Facilities GmbH (CSF),
6 Dr-Bohr-Gasse 3, A-1030 Vienna, Austria, Europe.
7 All rights reserved.
8 
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are
11 met:
12 
13  * Redistributions of source code must retain the above copyright notice,
14  this list of conditions and the following disclaimer.
15  * Redistributions in binary form must reproduce the above copyright notice,
16  this list of conditions and the following disclaimer in the documentation
17  and/or other materials provided with the distribution.
18  * Neither the name of the Campus Science Support Facilities GmbH
19  nor the names of its contributors may be used to endorse
20  or promote products derived from this software without specific prior
21  written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
24 AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
26 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
27 THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
31 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 </LICENSE> */
35 #ifndef MULTOVL_BASEPIPELINE_HEADER
36 #define MULTOVL_BASEPIPELINE_HEADER
37 
38 // == Header basepipeline.hh ==
39 
43 
44 // -- Own headers --
45 
46 #include "errors.hh"
47 
48 // -- Boost headers --
49 
50 #include "boost/noncopyable.hpp"
51 
52 // -- Standard headers --
53 
54 #include <string>
55 
56 namespace multovl {
57 
59 class MultovlOptbase;
60 
61 // -- Classes --
62 
69 class BasePipeline: private boost::noncopyable
70 {
71 public:
72 
75  _optpimpl(NULL), // derived classes allocate this
76  _inputs(),
77  _errors()
78  {}
79 
82  bool run();
83 
85  const Errors& errors() const { return _errors; }
86 
87  virtual
88  ~BasePipeline()
89  {}
90 
94  struct Input
95  {
96  std::string name;
97  unsigned int trackid, regcnt;
98 
99  explicit Input(const std::string& nm = ""):
100  name(nm), trackid(0), regcnt(0)
101  {}
102  };
103 
104 protected:
105 
106  typedef std::vector<Input> input_seq_t;
107 
110  virtual
111  unsigned int read_input() = 0;
112 
115  virtual
116  unsigned int detect_overlaps() = 0;
117 
123  virtual
124  bool write_output() = 0;
125 
129  bool set_optpimpl(MultovlOptbase* optp);
130 
132  MultovlOptbase* opt_pimpl() { return _optpimpl; }
133 
135  virtual
136  MultovlOptbase* opt_ptr() = 0;
137 
139  const input_seq_t& inputs() const { return _inputs; }
140 
142  input_seq_t& inputs() { return _inputs; }
143 
145  void add_error(const std::string& prefix,
146  const std::string& what) { _errors.add_error(prefix + ": " + what); }
147 
150  void add_all_errors(const Errors& other) { _errors += other; }
151 
153  void add_warning(const std::string& prefix,
154  const std::string& what) { _errors.add_warning(prefix + ": " + what); }
155 
157  void clear_errors() { _errors.clear(); }
158 
159 private:
160 
161  // Each derived class will have its option-handling object
162  // which is derived from MultovlOptbase (parallel inheritance hierarchy).
163  // The ptr to it remains NULL in this base class.
164  MultovlOptbase* _optpimpl;
165  input_seq_t _inputs;
166  Errors _errors;
167 };
168 
169 } // namespace multovl
170 
171 #endif // MULTOVL_BASEPIPELINE_HEADER
bool set_optpimpl(MultovlOptbase *optp)
void add_error(const std::string &msg)
void clear()
Tell the calling object to forget all errors and warnings seen so far.
void add_warning(const std::string &msg)
MultovlOptbase * opt_pimpl()
Definition: basepipeline.hh:132
const Errors & errors() const
Definition: basepipeline.hh:85
Base class for option handling in the multovl family of tools.
Definition: multovlopts.hh:56
virtual bool write_output()=0
void clear_errors()
Clears the errors.
Definition: basepipeline.hh:157
virtual unsigned int detect_overlaps()=0
void add_error(const std::string &prefix, const std::string &what)
Adds an error message.
Definition: basepipeline.hh:145
void add_all_errors(const Errors &other)
Definition: basepipeline.hh:150
virtual MultovlOptbase * opt_ptr()=0
const input_seq_t & inputs() const
Definition: basepipeline.hh:139
Simple facility to keep track of errors and warnings.
Definition: errors.hh:49
BasePipeline()
Default init of a BasePipeline object.
Definition: basepipeline.hh:74
void add_warning(const std::string &prefix, const std::string &what)
Adds a warning message.
Definition: basepipeline.hh:153
virtual unsigned int read_input()=0
input_seq_t & inputs()
Definition: basepipeline.hh:142
Definition: basepipeline.hh:69
Definition: basepipeline.hh:94