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