WModuleOneToOneCombiner.h 5.27 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut 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.
//
// OpenWalnut 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 OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------

25 26
#ifndef WMODULEONETOONECOMBINER_H
#define WMODULEONETOONECOMBINER_H
27 28 29 30 31 32

#include <string>

#include <boost/shared_ptr.hpp>

#include "../WModule.h"
33 34
#include "../WModuleCombiner.h"
#include "../WModuleCombinerTypes.h"
35

36
#include "../WExportKernel.h"
37

38
/**
39
 * Base class for all combiners which apply one connection between two connectors of two modules.
40
 */
41
class EXPORT_KERNEL_DLL WModuleOneToOneCombiner: public WModuleCombiner
42 43 44 45
{
public:

    /**
46 47
     * Creates a combiner which sets up the specified modules and prototype combination. Specifying a NULL pointer to the srcModule parameter
     * causes the combiner to only add the target module without any connections. This is especially useful for modules which do not provide any
48
     * input which must be connected. It is possible to specify prototypes here. The will get created upon apply.
49
     *
50 51 52 53
     *
     * \param target            the target container
     * \param srcModule         the module whose output should be connected with the prototypes input
     * \param srcConnector      the output connector of the module
54
     * \param targetModule      the module/prototype to use for connecting the module with
55 56
     * \param targetConnector   the input connector of the prototype to connect with srcConnector.
     */
57 58 59
    WModuleOneToOneCombiner( boost::shared_ptr< WModuleContainer > target,
                    boost::shared_ptr< WModule > srcModule, std::string srcConnector,
                    boost::shared_ptr< WModule > targetModule, std::string targetConnector );
60 61 62

    /**
     * Creates a combiner which sets up the specified modules and prototype combination. This constructor automatically uses the kernel's root
63 64
     * container as target container. Specifying a NULL pointer to the srcModule parameter
     * causes the combiner to only add the target module without any connections. This is especially useful for modules which do not provide any
65
     * input which must be connected. It is possible to specify prototypes here. The will get created upon apply.
66 67 68
     *
     * \param srcModule         the module whose output should be connected with the prototypes input
     * \param srcConnector      the output connector of the module
69
     * \param targetModule      the module/prototype to use for connecting the module with
70 71
     * \param targetConnector   the input connector of the prototype to connect with srcConnector.
     */
72 73
    WModuleOneToOneCombiner( boost::shared_ptr< WModule > srcModule, std::string srcConnector,
                    boost::shared_ptr< WModule > targetModule, std::string targetConnector );
74 75 76 77

    /**
     * Destructor.
     */
78
    virtual ~WModuleOneToOneCombiner();
79 80 81 82 83

    /**
     * Apply the internal module structure to the target container. Be aware, that this operation might take some time, as modules can be
     * connected only if they are "ready", which, at least with WMData modules, might take some time. It applies the loaded project file.
     */
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
    virtual void apply() = 0;

    /**
     * Gets the source module. This module's output connector is connected with the target.
     *
     * \return the source module.
     */
    boost::shared_ptr< WModule > getSrcModule() const;

    /**
     * The output connector of m_srcModule to connect with m_targetConnector.
     *
     * \return the source module's output connector.
     */
    std::string getSrcConnector() const;

    /**
     * The module/prototype to connect with m_srcModule.
     *
     * \return the target module prototype.
     */
    boost::shared_ptr< WModule > getTargetModule() const;

    /**
     * The input connector the target module to connect with m_srcConnector.
     *
     * \return the target module's input connector.
     */
    std::string getTargetConnector() const;
113 114 115

protected:

116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
    /**
     * The source module to connect with the target
     */
    boost::shared_ptr< WModule > m_srcModule;

    /**
     * The output connector of m_srcModule to connect with m_targetConnector.
     */
    std::string m_srcConnector;

    /**
     * The module/prototype to connect with m_srcMdodule.
     */
    boost::shared_ptr< WModule > m_targetModule;

    /**
     * The input connector the target module to connect with m_srcConnector.
     */
    std::string m_targetConnector;

136 137 138
private:
};

139 140
#endif  // WMODULEONETOONECOMBINER_H

141