vcsl_axis.h
Go to the documentation of this file.
1 #ifndef vcsl_axis_h_
2 #define vcsl_axis_h_
3 //:
4 // \file
5 // \brief Axis descriptor: a dimension, a unit, a label
6 // \author Francois BERTEL
7 //
8 // \verbatim
9 // Modifications
10 // 2000/06/28 Francois BERTEL Creation. Adapted from IUE
11 // 2004/09/17 Peter Vanroose do not pass vcsl_unit objects; use vcsl_unit_sptr instead
12 // \endverbatim
13 
14 #include <string>
15 #include <utility>
16 #include <vbl/vbl_ref_count.h>
17 #ifdef _MSC_VER
18 # include <vcl_msvc_warnings.h>
19 #endif
20 #include <vcsl/vcsl_axis_sptr.h>
22 #include <vcsl/vcsl_unit_sptr.h>
23 
24 //: Axis descriptor: a dimension, a unit, a label
25 class vcsl_axis
26  : public vbl_ref_count
27 {
28  public:
29  //***************************************************************************
30  // Constructors/Destructor
31  //***************************************************************************
32 
33  //: Default constructor. Axis with length in meters and an empty label
34  vcsl_axis();
35 
36  //: Constructor from dimension. Unit is the standard one. Label is empty
37  explicit vcsl_axis(vcsl_dimension_sptr const& new_dimension);
38 
39  //: Constructor from dimension and unit. Label is empty
40  // REQUIRE: new_dimension.compatible_unit(new_unit)
41  vcsl_axis(vcsl_dimension_sptr const& new_dimension,
42  vcsl_unit_sptr const& new_unit);
43 
44  //: Constructor from dimension, unit and label
45  vcsl_axis(vcsl_dimension_sptr const& new_dimension,
46  vcsl_unit_sptr const& new_unit,
47  std::string new_label)
48  : dimension_(new_dimension), unit_(new_unit), label_(std::move(new_label)) {}
49 
50  // Copy constructor
51  vcsl_axis(const vcsl_axis &a)
53 
54  // Destructor
55  ~vcsl_axis() override = default;
56 
57  //***************************************************************************
58  // Status report
59  //***************************************************************************
60 
61  //: Return the dimension
63 
64  //: Return the unit of the dimension
65  vcsl_unit_sptr unit() const { return unit_; }
66 
67  //: Return the label of the axis
68  std::string label() const { return label_; }
69 
70  //***************************************************************************
71  // Status change
72  //***************************************************************************
73 
74  //: Set the dimension. The unit is set with the standard unit
75  void set_dimension(vcsl_dimension_sptr const& new_dimension);
76 
77  //: Set the dimension and the unit
78  // REQUIRE: new_dimension.compatible_unit(new_unit)
79  void set_dimension_and_unit(vcsl_dimension_sptr const& new_dimension,
80  vcsl_unit_sptr const& new_unit);
81 
82  //: Set the unit of the dimension
83  // REQUIRE dimension()->compatible_unit(new_unit)
84  void set_unit(vcsl_unit_sptr const& new_unit);
85 
86  //: Set the label
87  void set_label(std::string const& new_label) { label_=new_label; }
88 
89  protected:
90  //***************************************************************************
91  // Implementation
92  //***************************************************************************
93 
94  //: Dimension
96 
97  //: Unit of the dimension
99 
100  //: Label of the axis
101  std::string label_;
102 };
103 
104 #endif // vcsl_axis_h_
vcsl_axis(vcsl_dimension_sptr const &new_dimension, vcsl_unit_sptr const &new_unit, std::string new_label)
Constructor from dimension, unit and label.
Definition: vcsl_axis.h:45
vcsl_axis()
Default constructor. Axis with length in meters and an empty label.
Definition: vcsl_axis.cxx:16
void set_unit(vcsl_unit_sptr const &new_unit)
Set the unit of the dimension.
Definition: vcsl_axis.cxx:72
std::string label() const
Return the label of the axis.
Definition: vcsl_axis.h:68
void set_label(std::string const &new_label)
Set the label.
Definition: vcsl_axis.h:87
vcsl_unit_sptr unit_
Unit of the dimension.
Definition: vcsl_axis.h:98
vcsl_dimension_sptr dimension_
Dimension.
Definition: vcsl_axis.h:95
vcsl_axis(const vcsl_axis &a)
Definition: vcsl_axis.h:51
void set_dimension(vcsl_dimension_sptr const &new_dimension)
Set the dimension. The unit is set with the standard unit.
Definition: vcsl_axis.cxx:48
void set_dimension_and_unit(vcsl_dimension_sptr const &new_dimension, vcsl_unit_sptr const &new_unit)
Set the dimension and the unit.
Definition: vcsl_axis.cxx:58
Axis descriptor: a dimension, a unit, a label.
Definition: vcsl_axis.h:25
vcsl_unit_sptr unit() const
Return the unit of the dimension.
Definition: vcsl_axis.h:65
vcsl_dimension_sptr dimension() const
Return the dimension.
Definition: vcsl_axis.h:62
~vcsl_axis() override=default
std::string label_
Label of the axis.
Definition: vcsl_axis.h:101