Changeset 159 in pacpusframework


Ignore:
Timestamp:
Aug 1, 2013, 2:19:48 PM (11 years ago)
Author:
morasjul
Message:

Somme cleaning in InputOutputInterface.h and InputOutputBase.h

Location:
branches/2.0-beta1/include/Pacpus/kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0-beta1/include/Pacpus/kernel/InputOutputBase.h

    r153 r159  
    117117    {}
    118118
     119    // TODO for serealization prupose (not yet implemented !!!)
    119120    virtual void customEvent(QEvent* e)
    120121    {
     
    179180    }
    180181
     182    // TODO for serealization prupose (not yet implemented !!!)
    181183    void send(/*const*/ QByteArray & data)
    182184    {
  • branches/2.0-beta1/include/Pacpus/kernel/InputOutputInterface.h

    r153 r159  
    4242    {
    4343        // TODO check component state started
     44        //if(_component) get state
    4445        switch (event->type()) {
    4546        case TYPED_EVENT:
    4647            {
    47             // cast from Component to Component (T->T)
     48
    4849            PacpusTypedEvent<T> * typedEvent = dynamic_cast<PacpusTypedEvent<T> *> (event);
    4950
    50             LOG_DEBUG("Receiver " << getSignature() << " thread " << QThread::currentThread() << " Data & " << & typedEvent->data_);
     51            LOG_DEBUG("Receiver " << getSignature() << " thread " << QThread::currentThread());
    5152
    52             //if(_component) get state
     53
    5354
    5455            if (typedEvent->timerange() < 500 && readingMode() == TimeBounded) {
     
    5960            switch (readingMode()) {
    6061            case TimeBounded:
    61                 LOG_DEBUG("Input " << this->getSignature().leftJustified(20) << QString("Time bournded").leftJustified(15) << road_time()- typedEvent->t_ << "\t" << typedEvent->tr_);
    6262
    6363                if (road_time() - typedEvent->time() > typedEvent->timerange()) {
     
    7070
    7171            case GetLast:
    72                 LOG_DEBUG("Input " << this->getSignature().leftJustified(20) << QString("GetLast").leftJustified(15) << road_time() - typedEvent->t_ << "\t" << typedEvent->tr_);
    7372
    7473                (dynamic_cast<C*>(component())->*method)(typedEvent->data());
     
    7877
    7978            case NeverSkip:
    80                 LOG_DEBUG("Input " << this->getSignature().leftJustified(20) << QString("NeverSkip").leftJustified(15) << road_time() - typedEvent->t_ << "\t" << typedEvent->tr_);
     79                (dynamic_cast<C*>(component())->*method)(typedEvent->data());
     80                break;
    8181
    8282            default:
    83                 (dynamic_cast<C*>(component())->*method)(typedEvent->data());
     83                LOG_WARN("Unknown reading mode " << readingMode());
    8484            }
    8585            break;
    8686        }
    8787
    88             // from Connection interface to Component (G->T)
    89             /*            case GENERIC_EVENT2: {
    90                 PacpusTypedEvent<QByteArray> * genericEvent = dynamic_cast<PacpusTypedEvent<QByteArray> *> (event);
    91                 T data;
    92                 QByteArray& buf = (QByteArray&) genericEvent->data_;
    93                 QDataStream in(&buf,QIODevice::ReadOnly);
    94 
    95                 (dynamic_cast<C*>(_component)->*method)(data); // copy 8 X
    96                 break;
    97             }
    98 
    99                 // from Component to Connection interface (T->G) (Typed in QByteArray)
    100             case GENERIC_EVENT3: {
    101                 PacpusTypedEvent<T> * typedEvent = dynamic_cast<PacpusTypedEvent<T> *> (event);
    102                 (dynamic_cast<C*>(_component)->*method)(typedEvent->data_);     // copy 3 X
    103 
    104                 break;
    105             }*/
     88            // Add here new event type if needed
    10689
    10790        default:
     
    11295    }
    11396
     97    // TODO for Pulling mode (not yet implemented !!!)
    11498    T& getData() {
    11599        T data;
    116100        // TODO ask output data;
    117 
    118             //LOG4CXX_INFO(getLogger(), "Hello, World");
    119101
    120102        return data;
     
    123105protected:
    124106    void (C::*method)(const T&);
    125 
    126  /*   log4cxx::LoggerPtr& getLogger() {
    127         static log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger(    LOG4CXX_LOCATION.getClassName()));
    128         return logger;
    129     }*/
    130107
    131108};
     
    141118    void send(const T & data, road_time_t t = road_time(), road_timerange_t tr = 0)
    142119    {
     120        // FIXME Data Shared
    143121        //QSharedPointer<T> sharedPointer = new T(data);
    144122
     
    146124            QApplication::postEvent(it->getInterface(),new PacpusTypedEvent<T>(TYPED_EVENT,data,t,tr),it->getPriority()); // Event is delete by the event loop handler
    147125            //qDebug() << "sender " << it->getInterface()->getSignature() <<  " thread " << QThread::currentThread() << " Data & " << &data << " ";
    148             // TODO Data Shared
    149126        }
    150127    }
    151128
    152     /*    void send(const T & data, road_time_t t = road_time(), road_timerange_t tr = 0) {
    153         for(QList<ConnectionBase>::iterator it = _connection.begin(); it!=_connection.end(); ++it){
    154 
    155             if(it->getInterface()->getDataType() != QString(typeid(QByteArray).name()))
    156                 QApplication::postEvent(it->getInterface(),new PacpusTypedEvent<T>(TYPED_EVENT,data,t,tr),it->getPriority());
    157            else {
    158                 QByteArray buf;
    159                 QDataStream out(&buf,QIODevice::ReadWrite);
    160                 PacpusTypedEvent<QByteArray> * ev =new PacpusTypedEvent<QByteArray>(GENERIC_EVENT3,buf);
    161                 QApplication::postEvent(it->getInterface(),ev,it->getPriority()); // Copy 2 (ctor)
    162                 }
    163         }
    164     }
    165 
    166     // Used by Connection Interfaces only to pose generic event
    167         void sendGenericData(char * data, size_t size) {
    168         QByteArray buf(data,size);  // copy 5
    169         for(QList<ConnectionBase>::iterator it = _connection.begin(); it!=_connection.end(); ++it)
    170             QApplication::postEvent(it->getInterface(),new PacpusTypedEvent<QByteArray>(GENERIC_EVENT2,buf),it->getPriority()); // Copy 6(ctor)
    171 
    172 
    173     }
    174 */
    175129    size_t getDataSize()
    176130    {
Note: See TracChangeset for help on using the changeset viewer.