Project stdui: "Simple Type Dialog User-Interface"

|
Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

cthread.hxx

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Serge Lussier   *
00003  *   serge.lussier@videotron.ca   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #ifndef FELIXCTHREAD_HXX
00022 #define FELIXCTHREAD_HXX
00023 
00024 #include <sigc++/sigc++.h>
00025 #include <pthread.h>
00026 #include <string>
00027 
00028 namespace control {
00029 
00037 class cthread : public sigc::trackable
00038 {
00039 public:
00040     typedef sigc::signal<bool, cthread*>::iterator notifyhandle;
00041     cthread();
00042     cthread(const std::string& nameid, const sigc::slot<bool>& exec_hook);
00043     virtual ~cthread();
00044 
00048     cthread::notifyhandle notify_delegate( const sigc::slot<bool, cthread*>& _slot ) { return notify_.connect( _slot ); }
00053     bool release_delegate( const cthread::notifyhandle& _handle) {
00054         if( _handle->empty() ) return false;
00055         _handle->disconnect();
00056         return true;
00057     }
00058     bool run();
00059     bool exec_delegate( const sigc::slot<bool>& exec_hook);
00060 
00064     bool notify()
00065     {
00066         return notify_.emit(this);
00067     }
00068     bool exit();
00069 
00073     bool end_delegate( const sigc::slot<void>& end_hook )
00074     {
00075        end_.connect( end_hook );
00076        return true;
00077     }
00081               const std::string& name() const
00082         {
00083            return _name;
00084         }
00085 
00086 private:
00087     friend void *thread_start_entry(void*);
00088 
00089 
00091     sigc::signal<bool, cthread*> notify_;
00093     pthread_t _pthID;
00094     sigc::signal<bool> run_;
00095     sigc::signal<void> end_;
00096 protected:
00097     std::string _name;
00098 };
00099 
00100 }// namespace control
00101 
00102 #endif
00103 
00104 

API Documentation Generated by:  doxygen 1.4.0
About the author | Site started with trial version of DreamWeaver MX 2004 | Finalizing with  | Contact | ©2005, Serge Lussier ( Bretzel )