Commit 7f3d4de6 authored by Julien Wintz's avatar Julien Wintz
Browse files

Updating container vector support implementation.

parent a8a8dbf9
/* dtkContainerVector.h ---
*
/* dtkContainerVector.h ---
*
* Author: tkloczko
* Copyright (C) 2011 - Thibaud Kloczko, Inria.
* Created: Wed May 23 11:19:32 2012 (+0200)
......@@ -9,12 +9,12 @@
* Update #: 82
*/
/* Commentary:
*
/* Commentary:
*
*/
/* Change log:
*
*
*/
#ifndef DTKCONTAINERVECTOR_H
......@@ -23,6 +23,8 @@
#include "dtkAbstractContainerOrdered.h"
#include "dtkContainerSupportExport.h"
#include <dtkCoreSupport/dtkArray.h>
#include <QtCore>
// /////////////////////////////////////////////////////////////////
......@@ -44,19 +46,19 @@ public:
public:
void clear(void);
void append(const T& value);
void append(const dtkAbstractContainer<T>& values);
void append(const dtkContainerVector<T>& values);
void prepend(const T& value);
void prepend(const dtkAbstractContainer<T>& values);
void prepend(const dtkContainerVector<T>& values);
void remove(const T& value);
void remove(const dtkAbstractContainer<T>& values);
void remove(const dtkContainerVector<T>& values);
void insert(qlonglong index, const T& value);
void insert(qlonglong from, const dtkAbstractContainer<T>& values);
void insert(qlonglong from, qlonglong step, const dtkAbstractContainer<T>& values);
......@@ -64,7 +66,7 @@ public:
void insert(qlonglong from, const dtkContainerVector<T>& values);
void insert(qlonglong from, qlonglong step, const dtkContainerVector<T>& values);
void insert(qlonglong *indices, const dtkContainerVector<T>& values);
void replace(qlonglong index, const T& value);
void replace(qlonglong from, const dtkAbstractContainer<T>& values);
void replace(qlonglong from, qlonglong step, const dtkAbstractContainer<T>& values);
......@@ -72,7 +74,7 @@ public:
void replace(qlonglong from, const dtkContainerVector<T>& values);
void replace(qlonglong from, qlonglong step, const dtkContainerVector<T>& values);
void replace(qlonglong *indices, const dtkContainerVector<T>& values);
void removeAt(qlonglong index);
void removeAt(qlonglong from, qlonglong to, qlonglong step = 1);
......@@ -84,7 +86,7 @@ public:
public:
bool isEmpty(void) const;
bool contains(const T& value) const;
bool contains(const T& value) const;
bool contains(const dtkAbstractContainer<T>& values) const;
bool contains(const dtkContainerVector<T>& values) const;
......@@ -140,9 +142,11 @@ public:
public:
template <typename U> friend dtkContainerVector<U> dtkContainerVectorFromQVector(const QVector<U>& vector);
template <typename U> friend QVector<U> dtkContainerVectorToQVector(const dtkContainerVector<U>& vector);
template <typename U> friend dtkContainerVector<T> dtkContainerVectorFromDtkArray(const dtkArray<U>& vector);
template <typename U> friend dtkArray<U> dtkContainerVectorToDtkArray(const dtkContainerVector<U>& vector);
private:
QVector<T> m_vector;
dtkArray<T> m_vector;
};
// // /////////////////////////////////////////////////////////////////
......@@ -151,6 +155,8 @@ private:
template <typename T> dtkContainerVector<T> dtkContainerVectorFromQVector(const QVector<T>& vector);
template <typename T> QVector<T> dtkContainerVectorToQVector(const dtkContainerVector<T>& vector);
template <typename T> dtkContainerVector<T> dtkContainerVectorFromDtkArray(const dtkArray<T>& vector);
template <typename T> dtkArray<T> dtkContainerVectorToDtkArray(const dtkContainerVector<T>& vector);
// /////////////////////////////////////////////////////////////////
// dtkContainerVector implementation
......@@ -159,7 +165,7 @@ template <typename T> QVector<T> dtkContainerVectorToQVector(const dtkContainerV
#include "dtkContainerVector.tpp"
// /////////////////////////////////////////////////////////////////
//
//
// /////////////////////////////////////////////////////////////////
typedef dtkContainerVector<qreal> dtkContainerVectorReal;
......@@ -173,7 +179,7 @@ Q_DECLARE_METATYPE(dtkContainerVectorInteger );
Q_DECLARE_METATYPE(dtkContainerVectorInteger *);
// /////////////////////////////////////////////////////////////////
//
//
// /////////////////////////////////////////////////////////////////
#include <dtkMathSupport/dtkVector3D.h>
......
/* dtkContainerVector.tpp ---
*
* Author: tkloczko
* Copyright (C) 2011 - Thibaud Kloczko, Inria.
* Created: Wed May 23 12:30:17 2012 (+0200)
* Version: $Id$
* Last-Updated: Mon Sep 30 17:00:43 2013 (+0200)
* By: Julien Wintz
* Update #: 268
*/
/* Commentary:
*
*/
/* Change log:
*
*/
#ifndef DTKCONTAINERVECTOR_TPP
#define DTKCONTAINERVECTOR_TPP
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
// /////////////////////////////////////////////////////////////////
// dtkContainerVector implementation
......@@ -26,7 +20,7 @@
template <typename T> dtkContainerVector<T>::dtkContainerVector(void) : dtkAbstractContainerOrdered<T>()
{
};
template <typename T> dtkContainerVector<T>::dtkContainerVector(qlonglong size) : dtkAbstractContainerOrdered<T>(), m_vector(size)
......@@ -289,7 +283,7 @@ template <typename T> bool dtkContainerVector<T>::contains(const dtkAbstractCont
while(result && (i < size)) {
result = m_vector.contains(array[i++]);
}
return result;
};
......@@ -301,7 +295,7 @@ template <typename T> bool dtkContainerVector<T>::contains(const dtkContainerVec
while(result && (i < size)) {
result = m_vector.contains(values.at(i++));
}
return result;
};
......@@ -383,30 +377,30 @@ template <typename T> dtkContainerVector<T> *dtkContainerVector<T>::subContainer
template <typename T> const T *dtkContainerVector<T>::toArray(qlonglong& count) const
{
count = m_vector.count();
return m_vector.data();
return m_vector.rawData();
};
template <typename T> T *dtkContainerVector<T>::toArray(qlonglong& count)
{
count = m_vector.count();
return m_vector.data();
return m_vector.rawData();
};
template <typename T> T *dtkContainerVector<T>::array(void)
{
return m_vector.data();
return m_vector.rawData();
};
template <typename T> const T *dtkContainerVector<T>::array(void) const
{
return m_vector.data();
return m_vector.rawData();
};
template <typename T> const T *dtkContainerVector<T>::constArray(void) const
{
return m_vector.constData();
return m_vector.constRawData();
};
template <typename T> const T& dtkContainerVector<T>::operator [] (qlonglong index) const
......@@ -414,7 +408,7 @@ template <typename T> const T& dtkContainerVector<T>::operator [] (qlonglong ind
return m_vector.at(index);
};
template <typename T> T& dtkContainerVector<T>::operator [] (qlonglong index)
template <typename T> T& dtkContainerVector<T>::operator [] (qlonglong index)
{
return m_vector[index];
};
......@@ -486,7 +480,10 @@ template <typename T> bool dtkContainerVector<T>::isEqual(const dtkAbstractConta
template <typename T> dtkContainerVector<T> dtkContainerVector<T>::operator + (const dtkContainerVector<T>& other)
{
return (m_vector + other.m_vector);
dtkContainerVector<T> vec;
vec.m_vector = m_vector;
vec.m_vector += other.m_vector;
return vec;
};
template <typename T> dtkContainerVector<T>& dtkContainerVector<T>::operator += (const dtkContainerVector<T>& other)
......@@ -501,19 +498,36 @@ template <typename T> dtkContainerVector<T>& dtkContainerVector<T>::operator +=
return (*this);
};
template <typename T> dtkContainerVector<T> dtkContainerVectorFromQVector(const QVector<T>& vector)
template <typename T> inline dtkContainerVector<T> dtkContainerVectorFromQVector(const QVector<T>& vector)
{
dtkContainerVector<T> result;
result.m_vector = vector;
result.m_vector.setRawData(vector.data(), vector.size(), dtkArray<T>::Writable);
return result;
};
template <typename T> QVector<T> dtkContainerVectorToQVector(const dtkContainerVector<T>& vector)
template <typename T> inline QVector<T> dtkContainerVectorToQVector(const dtkContainerVector<T>& vector)
{
QVector<T> result(vector.count());
for (int i = 0; i < vector.count(); ++i)
result[i] = vector.m_vector[i];
return result;
};
template <typename T> inline dtkContainerVector<T> dtkContainerVectorFromDtkArray(const dtkArray<T>& vector)
{
dtkArray<T> result;
result.m_vector = vector;
return result;
};
template <typename T> inline dtkArray<T> dtkContainerVectorToDtkArray(const dtkContainerVector<T>& vector)
{
QVector<T> result(vector.m_vector);
dtkArray<T> result(vector.m_vector);
return result;
};
#endif
//
// dtkContainerVector.tpp ends here
/* dtkCore.h ---
*
/* dtkCore.h ---
*
* Author: Julien Wintz
* Created: Thu Feb 28 16:28:31 2013 (+0100)
* Version:
* Version:
* Last-Updated: mar. avril 15 11:09:21 2014 (+0200)
* By: Thibaud Kloczko
* Update #: 62
*/
/* Change Log:
*
*
*/
#pragma once
......
/* dtkTest.h ---
*
* Author: Julien Wintz
* Created: Mon Feb 4 15:02:54 2013 (+0100)
* Version:
* Last-Updated: Fri Mar 22 11:40:16 2013 (+0100)
* By: Julien Wintz
* Update #: 14
*/
/* Change Log:
*
*/
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
#include <QtTest>
#define DTKTEST_MAIN(TestMain, TestObject) \
#define DTKTEST_MAIN(TestMain, TestObject) \
int TestMain(int argc, char **argv) \
{ \
QApplication app(argc, argv); \
TestObject tc; \
return QTest::qExec(&tc, argc, argv); \
{ \
QApplication app(argc, argv); \
TestObject tc; \
return QTest::qExec(&tc, argc, argv); \
}
#define DTKTEST_MAIN_GUI(TestMain, TestObject) \
#define DTKTEST_MAIN_GUI(TestMain, TestObject) \
int TestMain(int argc, char **argv) \
{ \
QGuiApplication app(argc, argv); \
TestObject tc; \
return QTest::qExec(&tc, argc, argv); \
{ \
QGuiApplication app(argc, argv); \
TestObject tc; \
return QTest::qExec(&tc, argc, argv); \
}
#define DTKTEST_MAIN_NOGUI(TestMain, TestObject) \
int TestMain(int argc, char **argv) \
{ \
QCoreApplication app(argc, argv); \
TestObject tc; \
return QTest::qExec(&tc, argc, argv); \
int TestMain(int argc, char **argv) \
{ \
QCoreApplication app(argc, argv); \
TestObject tc; \
return QTest::qExec(&tc, argc, argv); \
}
//
// dtkTest.h ends here
Markdown is supported
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