[mathicgb] 292/393: Set up support for a callback to control the computation in the library interface. The interface is there now, though it doesn't do anything yet.
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:59:22 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to branch upstream
in repository mathicgb.
commit 97d909f028198ba37d9330772a3587016c3b7b31
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date: Sat Apr 20 16:47:50 2013 -0400
Set up support for a callback to control the computation in the library interface. The interface is there now, though it doesn't do anything yet.
---
src/mathicgb.cpp | 20 +++++++++++++++++++-
src/mathicgb.h | 41 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 59 insertions(+), 2 deletions(-)
diff --git a/src/mathicgb.cpp b/src/mathicgb.cpp
index c49c4a0..d8c780c 100755
--- a/src/mathicgb.cpp
+++ b/src/mathicgb.cpp
@@ -318,7 +318,9 @@ namespace mgb {
mReducer(DefaultReducer),
mMaxSPairGroupSize(0),
mMaxThreadCount(0),
- mLogging()
+ mLogging(),
+ mCallbackData(0),
+ mCallback(0)
#ifdef MATHICGB_DEBUG
, mHasBeenDestroyed(false)
#endif
@@ -349,6 +351,7 @@ namespace mgb {
MATHICGB_ASSERT(baseOrderValid(mBaseOrder));
MATHICGB_ASSERT(reducerValid(mReducer));
MATHICGB_ASSERT(mModulus != 0);
+ MATHICGB_ASSERT(mCallback != 0 || mCallbackData == 0);
MATHICGB_ASSERT_NO_ASSUME(!mHasBeenDestroyed);
#endif
return true;
@@ -362,6 +365,8 @@ namespace mgb {
size_t mMaxSPairGroupSize;
size_t mMaxThreadCount;
std::string mLogging;
+ void* mCallbackData;
+ Callback::Action (*mCallback) (void*);
MATHICGB_IF_DEBUG(bool mHasBeenDestroyed);
};
@@ -434,6 +439,19 @@ namespace mgb {
return data;
}
+ void GroebnerConfiguration::setCallbackInternal(
+ void* data,
+ Callback::Action (*func) (void*)
+ ) {
+ MATHICGB_ASSERT(func != 0 || data == 0);
+ mPimpl->mCallbackData = data;
+ mPimpl->mCallback = func;
+ }
+
+ void* GroebnerConfiguration::callbackDataInternal() const {
+ return mPimpl->mCallbackData;
+ }
+
void GroebnerConfiguration::setReducer(Reducer reducer) {
MATHICGB_ASSERT(Pimpl::reducerValid(reducer));
mPimpl->mReducer = reducer;
diff --git a/src/mathicgb.h b/src/mathicgb.h
index 6289cc8..f9617b5 100755
--- a/src/mathicgb.h
+++ b/src/mathicgb.h
@@ -122,6 +122,25 @@ namespace mgb { // Part of the public interface of MathicGB
void setLogging(const char* logging);
const char* logging() const;
+ /// Class used for setCallback().
+ class Callback {
+ public:
+ enum Action {
+ ContinueAction = 0,
+ StopWithNoOutputAction = 1,
+ StopWithPartialOutputAction = 2
+ };
+ virtual Action call() const = 0;
+ };
+
+ /// Set callback to be called at various unspecified times during
+ /// the computation. Callback has the ability to stop or continue
+ /// the computation based on its return value. If callback is null
+ /// then no function will be called.
+ void setCallback(Callback* callback);
+ Callback* callback();
+ const Callback* callback() const;
+
private:
friend class mgbi::PimplOf;
@@ -133,6 +152,10 @@ namespace mgb { // Part of the public interface of MathicGB
void setMonomialOrderInternal(MonomialOrderData order);
MonomialOrderData monomialOrderInternal() const;
+ static Callback::Action callbackCaller(void* obj);
+ void setCallbackInternal(void* data, Callback::Action (*func) (void*));
+ void* callbackDataInternal() const;
+
struct Pimpl;
Pimpl* mPimpl;
};
@@ -432,8 +455,24 @@ namespace mgb {
);
}
-
+ inline GroebnerConfiguration::Callback::Action
+ GroebnerConfiguration::callbackCaller(void* obj) {
+ return static_cast<Callback*>(obj)->call();
+ };
+
+ inline void GroebnerConfiguration::setCallback(Callback* callback) {
+ setCallbackInternal(static_cast<void*>(callback), callbackCaller);
+ }
+
+ inline const GroebnerConfiguration::Callback*
+ GroebnerConfiguration::callback() const {
+ return const_cast<GroebnerConfiguration&>(*this).callback();
+ }
+ inline GroebnerConfiguration::Callback*
+ GroebnerConfiguration::callback() {
+ return static_cast<Callback*>(callbackDataInternal());
+ }
// ** Implementation of the class IdealStreamLog
// This class has to be inline as it is a template.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mathicgb.git
More information about the debian-science-commits
mailing list