Changeset 202 in pacpusframework for trunk/include


Ignore:
Timestamp:
Oct 29, 2013, 3:40:48 PM (11 years ago)
Author:
Marek Kurdej
Message:

Added: OutputInterface::checkedSend.
Added: ComponentManager: prints InputsMap, OutputsMap.

Location:
trunk/include/Pacpus/kernel
Files:
2 edited

Legend:

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

    r201 r202  
    101101    QString getName() const;
    102102
    103     /// @todo DOC
    104     InputInterfaceBase * getInput(QString name) const;
    105 
    106     /// @todo DOC
    107     OutputInterfaceBase * getOutput(QString name) const;
    108 
    109103protected:
    110104    /// Changes the state of the component.
     
    155149        outputs().insert(name, connection);
    156150    }
     151   
     152    /// @todo DOC
     153    InputInterfaceBase * getInput(QString name) const;
     154
     155    /// @todo DOC
     156    OutputInterfaceBase * getOutput(QString name) const;
    157157
    158158    template <typename DataType, class ComponentType>
  • trunk/include/Pacpus/kernel/InputOutputInterface.h

    r200 r202  
    55#include <Pacpus/kernel/Log.h>
    66
    7 #include <QApplication>
    87#include <QByteArray>
    98#include <QCoreApplication>
     
    147146
    148147    for (QList<ConnectionBase>::iterator it = connections().begin(), itend = connections().end(); it != itend; ++it) {
    149         // Event is deleted by the event loop handler
    150         QApplication::postEvent(it->getInterface(), new PacpusTypedEvent<T>(TYPED_EVENT,data,t,tr),it->getPriority());
    151         //qDebug() << "sender " << it->getInterface()->getSignature() << " Data & " << &data << " ";
     148        // Qt documentatino:
     149        //  The event must be allocated on the heap since the post event queue will take ownership of the event and delete it once it has been posted.
     150        //  It is not safe to access the event after it has been posted.   
     151        QEvent * newEvent = new PacpusTypedEvent<T>(TYPED_EVENT, data, t, tr);
     152        QCoreApplication::postEvent(it->getInterface(), newEvent, it->getPriority());
     153        LOG_DEBUG("Sender: " << it->getInterface()->getSignature());
     154        LOG_DEBUG("Data &: " << &data);
    152155    }
     156}
     157
     158template <typename T1, typename T2, class C>
     159bool checkedSend(OutputInterface<T1, C> * sender, const T2 & data, road_time_t t = road_time(), road_timerange_t tr = 0);
     160
     161template <typename T1, typename T2, class C>
     162bool checkedSend(OutputInterface<T1, C> * sender, const T2 & data, road_time_t t, road_timerange_t tr)
     163{
     164    if (sender && sender->hasConnection()) {
     165        sender->send(data, t, tr);
     166        return true;
     167    }
     168    return false;
    153169}
    154170
Note: See TracChangeset for help on using the changeset viewer.