Ignore:
Timestamp:
01/25/17 16:25:17 (7 years ago)
Author:
yushan
Message:

initialize the branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_yushan/src/filter/input_pin.cpp

    r1006 r1037  
    11#include "input_pin.hpp" 
    2 #include "output_pin.hpp" 
    32#include "garbage_collector.hpp" 
    43#include "exception.hpp" 
     
    98    : gc(gc) 
    109    , slotsCount(slotsCount) 
    11     , triggers(slotsCount) 
    12     , hasTriggers(false) 
    1310  { /* Nothing to do */ } 
    1411 
     
    2623    { 
    2724      it = inputs.insert(std::make_pair(packet->timestamp, InputBuffer(slotsCount))).first; 
    28       gc.registerObject(this, packet->timestamp); 
     25      gc.registerFilter(this, packet->timestamp); 
    2926    } 
     27 
    3028    it->second.slotsFilled++; 
    3129    it->second.packets[inputSlot] = packet; 
     
    3432    { 
    3533      // Unregister before calling onInputReady in case the filter registers again 
    36       gc.unregisterObject(this, packet->timestamp); 
     34      gc.unregisterFilter(this, packet->timestamp); 
    3735      onInputReady(it->second.packets); 
    3836      inputs.erase(it); 
    3937    } 
    40   } 
    41  
    42   void CInputPin::setInputTrigger(size_t inputSlot, COutputPin* trigger) 
    43   { 
    44     if (inputSlot >= slotsCount) 
    45       ERROR("void CInputPin::setInputTrigger(size_t inputSlot, COutputPin* trigger)", 
    46             "The input slot " << inputSlot << " does not exist."); 
    47     if (triggers[inputSlot]) 
    48       ERROR("void CInputPin::setInputTrigger(size_t inputSlot, COutputPin* trigger)", 
    49             "The trigger for input slot " << inputSlot << " has already been set."); 
    50  
    51     triggers[inputSlot] = trigger; 
    52     hasTriggers = true; 
    53   } 
    54  
    55   void CInputPin::trigger(Time timestamp) 
    56   { 
    57     if (hasTriggers) // Don't use canBeTriggered here, this function is virtual and can be overriden 
    58     { 
    59       std::map<Time, InputBuffer>::iterator it = inputs.find(timestamp); 
    60       bool nothingReceived = (it == inputs.end()); 
    61  
    62       for (size_t s = 0; s < slotsCount; s++) 
    63       { 
    64         if (triggers[s] && (nothingReceived || !it->second.packets[s])) 
    65           triggers[s]->trigger(timestamp); 
    66       } 
    67     } 
    68   } 
    69  
    70   bool CInputPin::canBeTriggered() const 
    71   { 
    72     return hasTriggers; 
    7338  } 
    7439 
Note: See TracChangeset for help on using the changeset viewer.