Commit 3d63befa authored by KLOCZKO Thibaud's avatar KLOCZKO Thibaud
Browse files

Modification of transmitters API to fit with constness requirements.

parent 5f053eb6
......@@ -4,9 +4,9 @@
* Copyright (C) 2011 - Thibaud Kloczko, Inria.
* Created: Mon Jan 30 16:37:29 2012 (+0100)
* Version: $Id$
* Last-Updated: Thu May 10 11:02:30 2012 (+0200)
* Last-Updated: Wed May 16 11:55:39 2012 (+0200)
* By: tkloczko
* Update #: 203
* Update #: 206
*/
/* Commentary:
......@@ -52,12 +52,22 @@ dtkComposerTransmitter::~dtkComposerTransmitter(void)
d = NULL;
}
QVariant& dtkComposerTransmitter::variant(void)
{
return d->variant;
}
const QVariant& dtkComposerTransmitter::variant(void) const
{
return d->variant;
}
const dtkAbstractContainer& dtkComposerTransmitter::container(void)
dtkAbstractContainer& dtkComposerTransmitter::container(void)
{
return d->container;
}
const dtkAbstractContainer& dtkComposerTransmitter::container(void) const
{
return d->container;
}
......
......@@ -4,9 +4,9 @@
* Copyright (C) 2011 - Thibaud Kloczko, Inria.
* Created: Mon Jan 30 16:36:09 2012 (+0100)
* Version: $Id$
* Last-Updated: Thu May 10 11:02:22 2012 (+0200)
* Last-Updated: Wed May 16 11:55:17 2012 (+0200)
* By: tkloczko
* Update #: 156
* Update #: 161
*/
/* Commentary:
......@@ -55,10 +55,12 @@ public:
virtual QString kindName(void) const = 0;
public:
QVariant& variant(void);
const QVariant& variant(void) const;
public:
virtual const dtkAbstractContainer& container(void);
virtual dtkAbstractContainer& container(void);
virtual const dtkAbstractContainer& container(void) const;
public:
virtual QVariant::Type type(void) const;
......
......@@ -4,9 +4,9 @@
* Copyright (C) 2011 - Thibaud Kloczko, Inria.
* Created: Tue Feb 14 10:33:49 2012 (+0100)
* Version: $Id$
* Last-Updated: Thu May 10 10:43:52 2012 (+0200)
* Last-Updated: Wed May 16 12:01:11 2012 (+0200)
* By: tkloczko
* Update #: 70
* Update #: 76
*/
/* Commentary:
......@@ -38,16 +38,19 @@ public:
public:
inline void setData(const T& data);
inline const T& data(void);
inline T& data(void);
inline const T& data(void) const;
public:
inline void setVector(const dtkContainerVector<T>& vector);
inline dtkContainerVector<T>& vector(void);
inline const dtkContainerVector<T>& vector(void) const;
public:
inline void setList(const dtkContainerList<T>& list);
inline dtkContainerList<T>& list(void);
inline const dtkContainerList<T>& list(void) const;
public:
......
......@@ -4,9 +4,9 @@
* Copyright (C) 2011 - Thibaud Kloczko, Inria.
* Created: Tue Feb 14 10:37:37 2012 (+0100)
* Version: $Id$
* Last-Updated: Thu May 10 10:44:00 2012 (+0200)
* Last-Updated: Wed May 16 12:02:32 2012 (+0200)
* By: tkloczko
* Update #: 156
* Update #: 161
*/
/* Commentary:
......@@ -61,7 +61,16 @@ template <typename T> inline void dtkComposerTransmitterEmitter<T>::setData(cons
/*!
*
*/
template <typename T> inline const T& dtkComposerTransmitterEmitter<T>::data(void)
template <typename T> inline T& dtkComposerTransmitterEmitter<T>::data(void)
{
return m_data;
};
//! Returns the data as a modifiable reference.
/*!
*
*/
template <typename T> inline const T& dtkComposerTransmitterEmitter<T>::data(void) const
{
return m_data;
};
......@@ -79,6 +88,15 @@ template <typename T> inline void dtkComposerTransmitterEmitter<T>::setVector(co
}
};
//!
/*!
*
*/
template <typename T> inline dtkContainerVector<T>& dtkComposerTransmitterEmitter<T>::vector(void)
{
return m_vector;
};
//!
/*!
*
......@@ -101,6 +119,15 @@ template <typename T> inline void dtkComposerTransmitterEmitter<T>::setList(cons
}
};
//!
/*!
*
*/
template <typename T> inline dtkContainerList<T>& dtkComposerTransmitterEmitter<T>::list(void)
{
return m_list;
};
//!
/*!
*
......
......@@ -4,9 +4,9 @@
* Copyright (C) 2011 - Thibaud Kloczko, Inria.
* Created: Tue Feb 14 11:39:15 2012 (+0100)
* Version: $Id$
* Last-Updated: Thu May 10 10:45:47 2012 (+0200)
* Last-Updated: Wed May 16 11:59:19 2012 (+0200)
* By: tkloczko
* Update #: 74
* Update #: 79
*/
/* Commentary:
......@@ -41,13 +41,17 @@ public:
~dtkComposerTransmitterReceiver(void);
public:
const T& data(void);
T& data(void);
const T& data(void) const;
public:
dtkAbstractContainer& container(void);
const dtkAbstractContainer& container(void) const;
dtkContainerVector<T>& vector(void);
const dtkContainerVector<T>& vector(void) const;
dtkContainerList<T>& list(void);
const dtkContainerList<T>& list(void) const;
......
......@@ -4,9 +4,9 @@
* Copyright (C) 2011 - Thibaud Kloczko, Inria.
* Created: Tue Feb 14 12:56:04 2012 (+0100)
* Version: $Id$
* Last-Updated: Thu May 10 10:50:16 2012 (+0200)
* Last-Updated: Wed May 16 12:04:05 2012 (+0200)
* By: tkloczko
* Update #: 212
* Update #: 220
*/
/* Commentary:
......@@ -55,7 +55,7 @@ template <typename T> dtkComposerTransmitterReceiver<T>::~dtkComposerTransmitter
/*!
*
*/
template <typename T> const T& dtkComposerTransmitterReceiver<T>::data(void)
template <typename T> T& dtkComposerTransmitterReceiver<T>::data(void)
{
if (active_emitter)
return active_emitter->data();
......@@ -66,6 +66,36 @@ template <typename T> const T& dtkComposerTransmitterReceiver<T>::data(void)
return m_data;
};
//! Returns the data as a modifiable reference.
/*!
*
*/
template <typename T> const T& dtkComposerTransmitterReceiver<T>::data(void) const
{
if (active_emitter)
return active_emitter->data();
if (active_variant)
m_data = qvariant_cast<const T>(active_variant->data());
return m_data;
};
//!
/*!
*
*/
template <typename T> dtkAbstractContainer& dtkComposerTransmitterReceiver<T>::container(void)
{
if (active_emitter)
return active_emitter->container();
if (active_variant)
return active_variant->container();
return d->container;
};
//!
/*!
*
......@@ -81,6 +111,21 @@ template <typename T> const dtkAbstractContainer& dtkComposerTransmitterReceiver
return d->container;
};
//!
/*!
*
*/
template <typename T> dtkContainerVector<T>& dtkComposerTransmitterReceiver<T>::vector(void)
{
if (active_emitter)
return active_emitter->vector();
if (active_variant)
return *reinterpret_cast<dtkContainerVector<T> *>(&(active_variant->container()));
return m_vector;
};
//!
/*!
*
......@@ -96,6 +141,21 @@ template <typename T> const dtkContainerVector<T>& dtkComposerTransmitterReceive
return m_vector;
};
//!
/*!
*
*/
template <typename T> dtkContainerList<T>& dtkComposerTransmitterReceiver<T>::list(void)
{
if (active_emitter)
return active_emitter->list();
if (active_variant)
return *reinterpret_cast<dtkContainerList<T> *>(&(active_variant->container()));
return m_list;
};
//!
/*!
*
......
......@@ -4,9 +4,9 @@
* Copyright (C) 2011 - Thibaud Kloczko, Inria.
* Created: Sat Mar 3 17:51:22 2012 (+0100)
* Version: $Id$
* Last-Updated: Thu May 10 11:20:42 2012 (+0200)
* Last-Updated: Wed May 16 11:57:46 2012 (+0200)
* By: tkloczko
* Update #: 406
* Update #: 409
*/
/* Commentary:
......@@ -80,7 +80,21 @@ void dtkComposerTransmitterVariant::setData(const dtkAbstractContainer& data)
}
}
const QVariant& dtkComposerTransmitterVariant::data(void)
QVariant& dtkComposerTransmitterVariant::data(void)
{
if (e->twinned)
return d->variant;
if (e->active_variant)
return e->active_variant->data();
if (e->active_emitter)
return e->active_emitter->variant();
return d->variant;
}
const QVariant& dtkComposerTransmitterVariant::data(void) const
{
if (e->twinned)
return d->variant;
......@@ -123,7 +137,7 @@ QVariantList dtkComposerTransmitterVariant::allData(void)
return list;
}
const dtkAbstractContainer& dtkComposerTransmitterVariant::container(void)
const dtkAbstractContainer& dtkComposerTransmitterVariant::container(void) const
{
if (d->container.type() == dtkAbstractContainer::None) {
......@@ -140,6 +154,23 @@ const dtkAbstractContainer& dtkComposerTransmitterVariant::container(void)
return d->container;
}
dtkAbstractContainer& dtkComposerTransmitterVariant::container(void)
{
if (d->container.type() == dtkAbstractContainer::None) {
if (e->active_variant)
d->container = e->active_variant->container();
else if (e->active_emitter)
d->container = qvariant_cast<dtkAbstractContainer>(e->active_emitter->variant());
else
d->container = qvariant_cast<dtkAbstractContainer>(d->variant);
}
return d->container;
}
//!
/*!
*
......
......@@ -4,9 +4,9 @@
* Copyright (C) 2011 - Thibaud Kloczko, Inria.
* Created: Fri Mar 2 16:19:20 2012 (+0100)
* Version: $Id$
* Last-Updated: Thu May 10 10:40:21 2012 (+0200)
* Last-Updated: Wed May 16 11:58:14 2012 (+0200)
* By: tkloczko
* Update #: 72
* Update #: 76
*/
/* Commentary:
......@@ -39,12 +39,14 @@ public:
void setData(const QVariant& data);
void setData(const dtkAbstractContainer& data);
const QVariant& data(void);
QVariant& data(void);
const QVariant& data(void) const;
QVariantList allData(void);
public:
const dtkAbstractContainer& container(void);
dtkAbstractContainer& container(void);
const dtkAbstractContainer& container(void) const;
public:
bool isEmpty(void) const;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment