Changeset 207 in pacpusframework


Ignore:
Timestamp:
10/31/13 09:48:29 (11 years ago)
Author:
Marek Kurdej
Message:

Fixed bug in createConnection.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/Pacpus/kernel/ComponentManager.h

    r198 r207  
    8383     * @return True if the component exists and has been started, otherwise false.
    8484     */
    85     bool start(const QString& component);
     85    bool start(const QString & component);
    8686
    8787    /** Stop all the components
     
    119119    bool createComponent(const QString& type, const QString& name);
    120120
    121     bool checkComponentConnection(const QString& componentName, const QString& connectionName);
     121    bool checkComponent(const QString & componentName);
     122    bool checkComponentInput(const QString & componentName, const QString & inputName);
     123    bool checkComponentOutput(const QString & componentName, const QString & outputName);
     124
    122125    bool createConnection(const QString& type, const QString& name, const QString& , int );
    123126
  • trunk/src/PacpusLib/ComponentManager.cpp

    r206 r207  
    2121
    2222using namespace pacpus;
    23 
    24 //template <typename _Elem, typename _Traits, typename _ListElem>
    25 //std::basic_ostream<_Elem, _Traits> & operator<<(std::basic_ostream<_Elem, _Traits> & os, const QList<_ListElem> & list)
    26 //{
    27 //    typedef QList<_ListElem> ListType;
    28 //    for (ListType::const_iterator it = list.cbegin(), itend = list.cend(); it != itend; ++it) {
    29 //        os << *it << "\n";
    30 //    }
    31 //    return os;
    32 //}
    3323
    3424template <typename _Elem, typename _Traits, typename _ListElem>
     
    246236}
    247237
    248 bool ComponentManager::checkComponentConnection(const QString& componentName, const QString& connectionName)
     238bool ComponentManager::checkComponent(const QString & componentName)
    249239{
    250240    if (NULL == getComponent(componentName)) {
    251         LOG_WARN("cannot make connection : component " << componentName << " not found");
    252         return false;
    253     }
    254     if (NULL == getComponent(componentName)->getOutput(connectionName)) {
    255         LOG_WARN("cannot make connection : component " << componentName << " does not have input/output " << connectionName);
     241        LOG_WARN("component " << componentName << " does not exist");
     242        return false;
     243    }
     244    return true;
     245}
     246
     247bool ComponentManager::checkComponentInput(const QString & componentName, const QString & inputName)
     248{
     249    if (!checkComponent(componentName)) {
     250        return false;
     251    }
     252    if (NULL == getComponent(componentName)->getInput(inputName)) {
     253        LOG_WARN("cannot make connection: component " << componentName << " does not have input " << inputName);
     254        return false;
     255    }
     256    return true;
     257}
     258
     259bool ComponentManager::checkComponentOutput(const QString & componentName, const QString & outputName)
     260{
     261    if (!checkComponent(componentName)) {
     262        return false;
     263    }
     264    if (NULL == getComponent(componentName)->getOutput(outputName)) {
     265        LOG_WARN("cannot make connection: component " << componentName << " does not have output " << outputName);
    256266        return false;
    257267    }
     
    265275    QStringList input  = inputSignature.split(".");
    266276
    267     if (!checkComponentConnection(output[0], output[1])) {
    268         return false;
    269     }
    270     if (!checkComponentConnection(input[0], input[1])) {
     277    if (!checkComponentOutput(output[0], output[1])) {
     278        return false;
     279    }
     280    if (!checkComponentInput(input[0], input[1])) {
    271281        return false;
    272282    }
     
    400410
    401411        if (!createConnection(connectionOutput, connectionInput, connectionType,connectionPriority)) {
    402             LOG_ERROR("cannot create connection '" << connectionOutput+"=>"+connectionInput << "'");
     412            LOG_ERROR("cannot create connection '" << connectionOutput + " => " + connectionInput << "'");
    403413            continue;
    404414        }
Note: See TracChangeset for help on using the changeset viewer.