Changeset 1021 for XIOS/dev/dev_olga/src/filter/input_pin.cpp
- Timestamp:
- 01/10/17 14:36:29 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/src/filter/input_pin.cpp
r639 r1021 1 1 #include "input_pin.hpp" 2 #include "output_pin.hpp" 2 3 #include "garbage_collector.hpp" 3 4 #include "exception.hpp" … … 8 9 : gc(gc) 9 10 , slotsCount(slotsCount) 11 , triggers(slotsCount) 12 , hasTriggers(false) 10 13 { /* Nothing to do */ } 11 14 … … 23 26 { 24 27 it = inputs.insert(std::make_pair(packet->timestamp, InputBuffer(slotsCount))).first; 25 gc.register Filter(this, packet->timestamp);28 gc.registerObject(this, packet->timestamp); 26 29 } 27 30 it->second.slotsFilled++; … … 31 34 { 32 35 // Unregister before calling onInputReady in case the filter registers again 33 gc.unregister Filter(this, packet->timestamp);36 gc.unregisterObject(this, packet->timestamp); 34 37 onInputReady(it->second.packets); 35 38 inputs.erase(it); 36 39 } 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; 37 73 } 38 74
Note: See TracChangeset
for help on using the changeset viewer.