summaryrefslogtreecommitdiffstats
path: root/libdimensionxx/progress.cpp
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-10-04 19:04:59 +0000
committerTavian Barnes <tavianator@gmail.com>2009-10-04 19:04:59 +0000
commitc35d5af1c2845ad072525e69f3f7be01994bcc2f (patch)
treec4bc69e26814cc32332340faf29a3e09a6bd1eb5 /libdimensionxx/progress.cpp
parentf8bd4dda645fda617bf37e180d35e4ef82c88e40 (diff)
downloaddimension-c35d5af1c2845ad072525e69f3f7be01994bcc2f.tar.xz
Purge test suite and C++ wrapper - for now.
Diffstat (limited to 'libdimensionxx/progress.cpp')
-rw-r--r--libdimensionxx/progress.cpp133
1 files changed, 0 insertions, 133 deletions
diff --git a/libdimensionxx/progress.cpp b/libdimensionxx/progress.cpp
deleted file mode 100644
index 8132d8a..0000000
--- a/libdimensionxx/progress.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
- * *
- * 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 *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-#include "dimensionxx.hpp"
-
-namespace Dimension
-{
- // No-op virtual destructor
- Persist_Base::~Persist_Base()
- { }
-
- // Construct a dmnsn_progress* wrapper
- Progress::Progress(dmnsn_progress* progress)
- : m_progress(new dmnsn_progress*(progress))
- { }
-
- // Construct a dmnsn_progress* wrapper, with a known persister
- Progress::Progress(dmnsn_progress* progress, const Persister& persister)
- : m_progress(new dmnsn_progress*(progress)), m_persister(persister)
- { }
-
- // Finish the progress if not yet finished and we are unique
- Progress::~Progress()
- {
- if (m_progress && m_progress.unique()) {
- try {
- finish();
- } catch (...) {
- dmnsn_error(SEVERITY_MEDIUM, "Finishing worker thread failed.");
- }
- }
- }
-
- // Get the current progress
- double
- Progress::progress() const
- {
- return dmnsn_get_progress(dmnsn());
- }
-
- // Wait until progress() >= progress
- void
- Progress::wait(double progress) const
- {
- dmnsn_wait_progress(dmnsn(), progress);
- }
-
- // Start a new level of loop nesting
- void
- Progress::new_element(unsigned int total)
- {
- dmnsn_new_progress_element(dmnsn(), total);
- }
-
- // Increment the progress
- void
- Progress::increment()
- {
- dmnsn_increment_progress(dmnsn());
- }
-
- // Immediately finish the progress
- void
- Progress::done()
- {
- dmnsn_done_progress(dmnsn());
- }
-
- // Wait for progress completion
- void
- Progress::finish()
- {
- if (!m_progress) {
- throw Dimension_Error("Attempt to finish Progress twice.");
- }
-
- if (!m_progress.unique()) {
- throw Dimension_Error("Attempt to finish non-unique Progress.");
- }
-
- if (dmnsn_finish_progress(dmnsn()) != 0) {
- throw Dimension_Error("Worker thread failed.");
- }
-
- m_progress.reset(); // Don't try again
- }
-
- // Access the set of persisted objects
- Persister&
- Progress::persister()
- {
- return m_persister;
- }
-
- // Access the underlying dmnsn_progress*
-
- dmnsn_progress*
- Progress::dmnsn()
- {
- if (!m_progress) {
- throw Dimension_Error("Attempting to access finished array.");
- }
-
- return *m_progress;
- }
-
- const dmnsn_progress*
- Progress::dmnsn() const
- {
- if (!m_progress) {
- throw Dimension_Error("Attempting to access finished array.");
- }
-
- return *m_progress;
- }
-}