Changeset 207 in pacpusframework for trunk/src


Ignore:
Timestamp:
Oct 31, 2013, 9:48:29 AM (11 years ago)
Author:
Marek Kurdej
Message:

Fixed bug in createConnection.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.