From 706acbb46a91adef8ed2ec1d255802e93c59b65a Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 24 Jun 2009 21:28:40 +0000 Subject: New C++ dmnsn_progress* wrapper. --- libdimensionxx/dimensionxx/array.hpp | 4 +-- libdimensionxx/dimensionxx/progress.hpp | 62 +++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 libdimensionxx/dimensionxx/progress.hpp (limited to 'libdimensionxx/dimensionxx') diff --git a/libdimensionxx/dimensionxx/array.hpp b/libdimensionxx/dimensionxx/array.hpp index b13fa8a..dfbf1c8 100644 --- a/libdimensionxx/dimensionxx/array.hpp +++ b/libdimensionxx/dimensionxx/array.hpp @@ -21,8 +21,8 @@ #ifndef DIMENSIONXX_ARRAY_HPP #define DIMENSIONXX_ARRAY_HPP -#include -#include // For size_t +#include // For tr1::shared_ptr +#include // For size_t // dmnsn_array* wrapper. diff --git a/libdimensionxx/dimensionxx/progress.hpp b/libdimensionxx/dimensionxx/progress.hpp new file mode 100644 index 0000000..72099c4 --- /dev/null +++ b/libdimensionxx/dimensionxx/progress.hpp @@ -0,0 +1,62 @@ +/************************************************************************* + * Copyright (C) 2008 Tavian Barnes * + * * + * This file is part of The Dimension Library. * + * * + * The Dimension Library is free software; you can redistribute it and/ * + * or modify it under the terms of the GNU Lesser General Public License * + * as published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * The Dimension Library is distributed in the hope that it will be * + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this program. If not, see * + * . * + *************************************************************************/ + +#ifndef DIMENSIONXX_PROGRESS_HPP +#define DIMENSIONXX_PROGRESS_HPP + +#include // For tr1::shared_ptr + +// dmnsn_canvas* wrapper. + +namespace Dimension +{ + // dmnsn_progress* wrapper class to represent an asynchronous worker thread + class Progress + { + public: + explicit Progress(dmnsn_progress* progress); + // Progress(const Progress& progress); + + // Finishes the job without throwing + ~Progress(); + + double progress() const; + void wait(double progress) const; + + void new_element(unsigned int total); + void increment(); + void done(); + + // Wait for job to finish, throwing if the job failed + void finish(); + + // Access the wrapped C object. + dmnsn_progress* dmnsn(); + const dmnsn_progress* dmnsn() const; + + private: + // Copy assignment prohibited + Progress& operator=(const Progress&); + + std::tr1::shared_ptr m_progress; + }; +} + +#endif /* DIMENSIONXX_PROGRESS_HPP */ -- cgit v1.2.3