OpenWalnut 1.2.5

WModuleCombiner.h

00001 //---------------------------------------------------------------------------
00002 //
00003 // Project: OpenWalnut ( http://www.openwalnut.org )
00004 //
00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
00006 // For more information see http://www.openwalnut.org/copying
00007 //
00008 // This file is part of OpenWalnut.
00009 //
00010 // OpenWalnut is free software: you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as published by
00012 // the Free Software Foundation, either version 3 of the License, or
00013 // (at your option) any later version.
00014 //
00015 // OpenWalnut is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 // GNU Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public License
00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
00022 //
00023 //---------------------------------------------------------------------------
00024 
00025 #ifndef WMODULECOMBINER_H
00026 #define WMODULECOMBINER_H
00027 
00028 #include <boost/shared_ptr.hpp>
00029 
00030 #include "../common/WThreadedRunner.h"
00031 
00032 #include "WModuleContainer.h"
00033 
00034 #include "WExportKernel.h"
00035 /**
00036  * This is a base class for all module combination classes. The basic idea is to hide the actual combination work from others. These classes may
00037  * be useful in the GUI. The GUI can create a module combiner instance in a special way, with an interface the GUI wants to have. Then, the
00038  * kernel can construct the actual module graph out of it. Another purpose is some kind of project file loading. One can write a combiner which
00039  * loads projects files and creates a module graph out of it. The only think which all the combiners need to know: the target container. Derive
00040  * all specific combiner classes from this one.
00041  */
00042 class OWKERNEL_EXPORT WModuleCombiner: public WThreadedRunner,
00043                                          public boost::enable_shared_from_this< WModuleCombiner >
00044 {
00045 public:
00046 
00047     /**
00048      * Creates an empty combiner.
00049      *
00050      * \param target the target container where to add the modules to.
00051      */
00052     explicit WModuleCombiner( boost::shared_ptr< WModuleContainer > target );
00053 
00054     /**
00055      * Creates an empty combiner. This constructor automatically uses the kernel's root container as target container.
00056      */
00057     WModuleCombiner();
00058 
00059     /**
00060      * Destructor.
00061      */
00062     virtual ~WModuleCombiner();
00063 
00064     /**
00065      * Apply the internal module structure to the target container. Be aware, that this operation might take some time, as modules can be
00066      * connected only if they are "ready", which, at least with WMData modules, might take some time.
00067      *
00068      * \note: to have asynchronous loading, use run().
00069      */
00070     virtual void apply() = 0;
00071 
00072     /**
00073      * Run thread and call apply(). This is useful to apply a combiner asynchronously.
00074      */
00075     virtual void run();
00076 
00077 protected:
00078 
00079     /**
00080      * Function that has to be overwritten for execution. It gets executed in a separate thread after run()
00081      * has been called. It actually calls apply() in another thread.
00082      */
00083     virtual void threadMain();
00084 
00085     /**
00086      * The module container to use for the modules.
00087      */
00088     boost::shared_ptr< WModuleContainer > m_container;
00089 
00090 private:
00091 };
00092 
00093 #endif  // WMODULECOMBINER_H
00094 
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends