source: XIOS/trunk/src/filter/input_pin.cpp @ 637

Last change on this file since 637 was 637, checked in by rlacroix, 9 years ago

Add the base classes for the new filter framework.

File size: 981 bytes
Line 
1#include "input_pin.hpp"
2#include "exception.hpp"
3
4namespace xios
5{
6  CInputPin::CInputPin(size_t slotsCount)
7    : slotsCount(slotsCount)
8  { /* Nothing to do */ }
9
10  void CInputPin::setInput(size_t inputSlot, CDataPacketPtr packet)
11  {
12    if (inputSlot >= slotsCount)
13      ERROR("void CInputPin::setInput(size_t inputSlot, CDataPacketPtr packet)",
14            "The input slot " << inputSlot << " does not exist.");
15    if (!packet)
16      ERROR("void CInputPin::setInput(size_t inputSlot, CDataPacketPtr packet)",
17            "The packet cannot be null.");
18
19    std::map<Time, InputBuffer>::iterator it = inputs.find(packet->timestamp);
20    if (it == inputs.end())
21      it = inputs.insert(std::make_pair(packet->timestamp, InputBuffer(slotsCount))).first;
22    it->second.slotsFilled++;
23    it->second.packets[inputSlot] = packet;
24
25    if (it->second.slotsFilled == slotsCount)
26    {
27      onInputReady(it->second.packets);
28      inputs.erase(it);
29    }
30  }
31} // namespace xios
Note: See TracBrowser for help on using the repository browser.