Class: Vigilem::Evdev::TransferAgent

Inherits:
Core::TransferAgent
  • Object
show all
Defined in:
lib/vigilem/evdev/transfer_agent.rb

Class Method Summary collapse

Class Method Details

.acquire(args = {}) ⇒ TransferAgent

TODO:

move away from singleton and look at the one used by x11

Parameters:

  • args (Hash) (defaults to: {})
  • :inputs (Array)
  • :outputs (Hash{observer_object => {event_opts}] @see Demultiplexer#add_oberver)

    outputs [Hash=> {event_opts] @see Demultiplexer#add_oberver

Returns:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/vigilem/evdev/transfer_agent.rb', line 21

def acquire(args={})
  if @transfer_agent
    @transfer_agent.multiplexer.add_inputs(*args[:inputs]) if args[:inputs]
    @transfer_agent.add_observers(args[:outputs]) if args[:outputs]
    if ((din = @transfer_agent.demultiplexer.input) || (mout = @transfer_agent.multiplexer.out)).nil? or not mout.equal?(din)
      @transfer_agent.demultiplexer.input = @transfer_agent.multiplexer.out = (mout || din || [])
    end
    @transfer_agent
  else
    m = Multiplexer.acquire(args[:inputs])
    d = Demultiplexer.acquire(args[:outputs])
    @transfer_agent = new(d, m)
  end
end