VoluMillGUI/ProgressDialog.h

Go to the documentation of this file.
00001 //-------------------------------------------------------------------
00004 //  Copyright (c) 2007 Celeritive Technologies, Inc.
00005 //
00006 //  Licensed under the Apache License, Version 2.0 (the "License");
00007 //  you may not use this file except in compliance with the License.
00008 //  You may obtain a copy of the License at
00009 //
00010 //     http://www.apache.org/licenses/LICENSE-2.0
00011 //
00012 //  Unless required by applicable law or agreed to in writing, software
00013 //  distributed under the License is distributed on an "AS IS" BASIS,
00014 //  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 //  See the License for the specific language governing permissions and
00016 //  limitations under the License.
00017 //
00018 //-------------------------------------------------------------------
00019 #pragma once
00020 #include "afxcmn.h"
00021 
00022 #include <boost/thread/thread.hpp>
00023 #include <boost/thread/mutex.hpp>
00024 #include <threadpool.hpp>
00025 
00026 #include "XmlRpc.h"
00027 
00028 // ProgressDialog dialog
00029 
00030 class ProgressData : boost::noncopyable
00031 {
00032 public:
00033    ProgressData(const std::string& hostname, int port)
00034       : m_jobId (-1), m_progress (0.0), m_client (hostname.c_str(), port), m_tp (1) {}
00035    int getJobId () const { boost::mutex::scoped_lock lock (m_dataMutex); return m_jobId; }
00036    void setJobId (int jobId) { boost::mutex::scoped_lock lock (m_dataMutex); m_jobId = jobId; }
00037    double getProgress () const { boost::mutex::scoped_lock lock (m_dataMutex); return m_progress; }
00038    void setProgress (double progress) { boost::mutex::scoped_lock lock (m_dataMutex); m_progress = progress; }
00039 
00040    boost::threadpool::pool& getThreadPool () { return m_tp; }
00041    int execute (const char* name, XmlRpc::XmlRpcValue& args, XmlRpc::XmlRpcValue& result)
00042    {
00043       boost::mutex::scoped_lock lock (m_clientMutex);
00044       return m_client.execute (name, args, result);
00045    }
00046 private:
00047    int m_jobId;
00048    double m_progress;
00049    mutable boost::mutex m_dataMutex;
00050    mutable boost::mutex m_clientMutex;
00051 
00052    boost::threadpool::pool m_tp;
00053    XmlRpc::XmlRpcClient m_client;
00054 };
00055 
00056 class ProgressDialog : public CDialog
00057 {
00058         DECLARE_DYNAMIC(ProgressDialog)
00059 
00060 public:
00061    ProgressDialog(boost::shared_ptr<ProgressData> ppd, CWnd* pParent = NULL);   // standard constructor
00062         virtual ~ProgressDialog();
00063 
00064 // Dialog Data
00065         enum { IDD = IDD_PROGRESS_DIALOG };
00066 
00067 protected:
00068         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00069    virtual BOOL OnInitDialog ();
00070         afx_msg void OnTimer(UINT nIDEvent);
00071    virtual void OnCancel();
00072 
00073         DECLARE_MESSAGE_MAP()
00074 private:
00075    boost::shared_ptr<ProgressData> m_ppd;
00076 };

Generated on Tue Jan 29 21:37:57 2008 for VoluMill Universal Client by  doxygen 1.4.6