Developer documentation | Axl-2.5.1

axlDouble.cpp
Go to the documentation of this file.
1 /* axlDouble.cpp ---
2  *
3  * Author: Anais Ducoffe
4  * Copyright (C) 2012 - Anais Ducoffe, Inria.
5  */
6 
7 /* Commentary:
8  *
9  */
10 
11 /* Change log:
12  *
13  */
14 
15 #include "axlDouble.h"
16 
17 #include "axlPoint.h"
18 
19 #include <dtkCoreSupport/dtkGlobal.h>
20 
21 // /////////////////////////////////////////////////////////////////
22 // axlDoublePrivate
23 // /////////////////////////////////////////////////////////////////
24 
25 class axlDoublePrivate
26 {
27 public:
28  double value;
29 };
30 
31 // /////////////////////////////////////////////////////////////////
32 // axlDouble implementation
33 // /////////////////////////////////////////////////////////////////
34 
35 axlDouble::axlDouble(QObject *parent) : axlAbstractData(), d(new axlDoublePrivate)
36 {
37  d->value = 0.0;
38 }
39 
40 
41 axlDouble::axlDouble(double value, QObject *parent) : axlAbstractData(), d(new axlDoublePrivate)
42 {
43  d->value = value;
44 }
45 
46 
47 
49 
52 axlDouble::axlDouble(const axlDouble& other) : axlAbstractData(), d(new axlDoublePrivate)
53 {
54  this->setParent(other.parent());
55  d->value = other.value();
56 }
57 
59 
63 {
64  delete d;
65  d = NULL;
66 }
67 
69 
73 {
74  d->value= other.value();
75  return (*this);
76 }
77 
78 
79 double axlDouble::value(void) const{
80  return d->value;
81 }
82 
83 void axlDouble::setValue(double newValue)
84 {
85  d->value = newValue;
86  this->touchGeometry();
87 }
88 
89 
90 // /////////////////////////////////////////////////////////////////
91 // Debug operators
92 // /////////////////////////////////////////////////////////////////
93 
94 QDebug operator<<(QDebug dbg, axlDouble value)
95 {
96  dbg.nospace() << value.description();
97 
98  return dbg.space();
99 }
100 
101 QDebug operator<<(QDebug dbg, axlDouble& value)
102 {
103  dbg.nospace() << value.description();
104 
105  return dbg.space();
106 }
107 
108 QDebug operator<<(QDebug dbg, axlDouble *value)
109 {
110  dbg.nospace() << value->description();
111 
112  return dbg.space();
113 }
114 
115 QString axlDouble::description(void) const
116 {
117  QString result = "axlDouble";
118  result.append("\n value : "+QString::number(d->value) );
119  return result;
120 }
121 
122 QString axlDouble::identifier(void) const
123 {
124  return "axlDouble";
125 }
126 
127 
128 QVariantList axlDouble::convertDataToQVariant(void) const{
129  QVariantList list;
130  QVariant id = QVariant::fromValue(identifier());
131  list.append(id);
132  QVariant value = QVariant::fromValue(d->value);
133  list.append(value);
134  return list;
135 
136 }
137 
138 int axlDouble::convertQVariantToData(const QVariantList &data){
139  d->value = data.last().toDouble();
140  return 1;
141 }
142 
143 // /////////////////////////////////////////////////////////////////
144 // Type instanciation
145 // /////////////////////////////////////////////////////////////////
146 
147 dtkAbstractData *createaxlDouble(void)
148 {
149  return new axlDouble();
150 
151 }
152 
153 
154 // /////////////////////////////////////////////////////////////////
155 // axlDouble documentation
156 // /////////////////////////////////////////////////////////////////
157 
void touchGeometry(void)
~axlDouble(void)
Destroys the axel double.
Definition: axlDouble.cpp:62
QVariantList convertDataToQVariant(void) const
Definition: axlDouble.cpp:128
Class axlDouble defines a double.
Definition: axlDouble.h:29
virtual QString identifier(void) const
Definition: axlDouble.cpp:122
int convertQVariantToData(const QVariantList &data)
Definition: axlDouble.cpp:138
dtkAbstractData * createaxlDouble(void)
Definition: axlDouble.cpp:147
QDebug operator<<(QDebug dbg, axlDouble value)
Definition: axlDouble.cpp:94
axlDouble(QObject *parent=0)
Definition: axlDouble.cpp:35
double value(void) const
Definition: axlDouble.cpp:79
Class axlAbstractData defines an API for all type of axel data.
axlDouble & operator=(const axlDouble &other)
Assigns other to this double and returns a reference to this double.
Definition: axlDouble.cpp:72
void setValue(double newValue)
Definition: axlDouble.cpp:83
virtual QString description(void) const
Definition: axlDouble.cpp:115