diff --git a/Project.toml b/Project.toml index cc30263d..32826999 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Causal" uuid = "c45f814d-238a-4fdc-b3d7-673e55950ac7" authors = ["Zekeriya Sarı ", "Serkan Günel "] -version = "0.3.1" +version = "0.3.2" [deps] DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" diff --git a/src/components/sinks/sinks.jl b/src/components/sinks/sinks.jl index d1ba0924..5c79e774 100644 --- a/src/components/sinks/sinks.jl +++ b/src/components/sinks/sinks.jl @@ -50,35 +50,34 @@ macro def_sink(ex) :( buflen::Int = 64 ), :( plugin::$PLUGIN_TYPE_SYMBOL = nothing ), :( timebuf::$TIMEBUF_TYPE_SYMBOL = Buffer(buflen) ), - :( databuf::$DATABUF_TYPE_SYMBOL = Causal.construct_sink_buffers(input, buflen) ), - :( sinkcallback::$SINK_CALLBACK_TYPE_SYMBOL = - Causal.construct_sink_callback(databuf, timebuf, plugin, action, id) ), + :( databuf::$DATABUF_TYPE_SYMBOL = length(input) == 1 ? Buffer(buflen) : Buffer(length(input), buflen) ), + :( sinkcallback::$SINK_CALLBACK_TYPE_SYMBOL = plugin === nothing ? + Callback(sink->ishit(databuf), sink->action(sink, outbuf(timebuf), outbuf(databuf)), true, id) : + Callback(sink->ishit(databuf), sink->action(sink, outbuf(timebuf), plugin.process(outbuf(databuf))), true, id) ), ]) quote Base.@kwdef $ex end |> esc end -# FIXME: Buffer types are not compatible for callbacks. Revise the buffer types. -# FIXME: When this bug is fixed, revise also the read method to read data files. -function construct_sink_buffers(input, buflen) - T = datatype(input) - n = length(input) - n == 1 ? Buffer(T, buflen) : [Buffer(T, buflen) for i in 1 : n] -end +# function construct_sink_buffers(input, buflen) +# T = datatype(input) +# n = length(input) +# n == 1 ? Buffer(T, buflen) : [Buffer(T, buflen) for i in 1 : n] +# end -construct_sink_callback(databuf::Buffer, timebuf, plugin::Nothing, action, id) = - Callback(sink->ishit(timebuf), sink->action(sink, reverse(timebuf.output), reverse(databuf.output)), true, id) +# construct_sink_callback(databuf::Buffer, timebuf, plugin::Nothing, action, id) = +# Callback(sink->ishit(timebuf), sink->action(sink, reverse(timebuf.output), reverse(databuf.output)), true, id) -construct_sink_callback(databuf::AbstractVector{<:Buffer}, timebuf, plugin::Nothing, action, id) = - Callback(sink->ishit(timebuf), sink->action(sink, reverse(timebuf.output), hcat([reverse(buf.output) for buf in databuf]...)), true, id) +# construct_sink_callback(databuf::AbstractVector{<:Buffer}, timebuf, plugin::Nothing, action, id) = +# Callback(sink->ishit(timebuf), sink->action(sink, reverse(timebuf.output), hcat([reverse(buf.output) for buf in databuf]...)), true, id) -construct_sink_callback(databuf::Buffer, timebuf, plugin::AbstractPlugin, action, id) = - Callback(sink->ishit(timebuf), sink->action(sink, reverse(timebuf.output), plugin.process(reverse(databuf.output))), true, id) +# construct_sink_callback(databuf::Buffer, timebuf, plugin::AbstractPlugin, action, id) = +# Callback(sink->ishit(timebuf), sink->action(sink, reverse(timebuf.output), plugin.process(reverse(databuf.output))), true, id) -construct_sink_callback(databuf::AbstractVector{<:Buffer}, timebuf, plugin::AbstractPlugin, action, id) = - Callback(sink->ishit(timebuf), sink->action(sink, reverse(timebuf.output), plugin.process(hcat([reverse(buf.output) for buf in databuf]...))), - true, id) +# construct_sink_callback(databuf::AbstractVector{<:Buffer}, timebuf, plugin::AbstractPlugin, action, id) = +# Callback(sink->ishit(timebuf), sink->action(sink, reverse(timebuf.output), plugin.process(hcat([reverse(buf.output) for buf in databuf]...))), +# true, id) ##### Define sink library