Belle II Software  release-05-02-19
BaseConstraint.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * See https://github.com/tferber/OrcaKinfit, forked from *
4  * https://github.com/iLCSoft/MarlinKinfit *
5  * *
6  * Further information about the fit engine and the user interface *
7  * provided in MarlinKinfit can be found at *
8  * https://www.desy.de/~blist/kinfit/doc/html/ *
9  * and in the LCNotes LC-TOOL-2009-001 and LC-TOOL-2009-004 available *
10  * from http://www-flc.desy.de/lcnotes/ *
11  * *
12  * Adopted by: Torben Ferber (torben.ferber@desy.de) (TF) *
13  * *
14  * This software is provided "as is" without any warranty. *
15  **************************************************************************/
16 
17 #include "analysis/OrcaKinFit/BaseConstraint.h"
18 
19 #include <cassert>
20 #include <cstring>
21 #include <iostream>
22 
23 namespace Belle2 {
28  namespace OrcaKinFit {
29 
31  : name(nullptr)
32  {
33  setName("???");
34  }
35 
36  BaseConstraint::BaseConstraint(const BaseConstraint& rhs)
37  : name(nullptr)
38  {
39  if (rhs.name) setName(rhs.name);
40  else setName("???");
41  }
42  BaseConstraint& BaseConstraint::operator= (const BaseConstraint& rhs)
43  {
44  if (this != &rhs) {
45  if (rhs.name) setName(rhs.name);
46  else setName("???");
47  }
48  return *this;
49  }
50 
52  {
53  delete[] name;
54  }
55 
56  const char* BaseConstraint::getName() const
57  {
58  return name;
59  }
60 
61  void BaseConstraint::setName(const char* name_)
62  {
63  if (name_ == nullptr) return;
64  size_t l = strlen(name_);
65  if (name) delete[] name;
66  name = new char[l + 1];
67  strcpy(name, name_);
68  }
69 
70  double BaseConstraint::getError() const
71  {
72  assert(false);
73  return 0;
74  }
75 
76  std::ostream& BaseConstraint::print(std::ostream& os) const
77  {
78  os << getName() << "=" << getValue();
79  return os;
80  }
81 
82  }// end OrcaKinFit namespace
84 } // end Belle2 namespace
Belle2::OrcaKinFit::BaseConstraint::getName
virtual const char * getName() const
Returns the name of the constraint.
Definition: BaseConstraint.cc:70
Belle2::OrcaKinFit::BaseConstraint::operator=
BaseConstraint & operator=(const BaseConstraint &rhs)
Assignment.
Definition: BaseConstraint.cc:56
Belle2::OrcaKinFit::BaseConstraint::BaseConstraint
BaseConstraint()
Creates an empty BaseConstraint object.
Definition: BaseConstraint.cc:44
Belle2::OrcaKinFit::BaseConstraint::setName
void setName(const char *name_)
Set object's name.
Definition: BaseConstraint.cc:75
Belle2::OrcaKinFit::BaseConstraint::print
virtual std::ostream & print(std::ostream &os) const
print object to ostream
Definition: BaseConstraint.cc:90
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::OrcaKinFit::BaseConstraint::getValue
virtual double getValue() const =0
Returns the value of the constraint function.
Belle2::OrcaKinFit::BaseConstraint::~BaseConstraint
virtual ~BaseConstraint()
Virtual destructor.
Definition: BaseConstraint.cc:65
Belle2::OrcaKinFit::BaseConstraint::getError
virtual double getError() const
Returns the error on the value of the constraint.
Definition: BaseConstraint.cc:84