Object manipulation chain

in my application I have three interfaces ICapture<T>, IDecoder<T, K>and IBroadcaster<K>.

Now I implement, for example, a class VideoCapturethat inherits from Capture<IntPtr>(IntPtr is the raw data created by the class). When data is generated by an object VideoCapture, I first want to decode it from Tto K, and then translate it.

I want to know how you would relate this? Just by writing a method like

var data = videoCapture.GetData();
var decoded = decoder.Decode(data);
broadcaster.Broadcast(decoded);

Or are there any design patterns I could use? I know the chain of responsibility. I could imagine classes like CaptureHandler, DecoderHandlerand BroadcastHandler, inheriting from HandlerBase. HandlerBasewill provide mechanisms for passing objects to the next handler.

var handler1 = new CaptureHandler();
var handler2 = new DecodeHandler();
handler1.SetNext(handler2);
handler1.Handle(object);

, .

+5
2

. , , , :

Decoder(VideoCapture<T> captureDevice)
{
}

Broadcaster, .. , .

, , . , . , . , Type .

, , OO .

, Capture, GetData(). . "CapturePal", "CaptureSecam", "CaptureMeSecam" .. , , , (if Capture<float>() , Capture<StringBuilder>() ?).

, , Decoder Broadcaster. , "DivxDecoder", "MpegDecoder". Broadcaster "TVBroadcaster", "IPBroadcaster", "TCPBroadcaster" ..

.

var myProcessingChain = new TVBroadcaster(new DivxDecoder (new CaptureSecam(inputData))));

, .

- . , , , .

, Generics. , , . , , . , .

+1

? , .

GetData = > Decode = > Broadcast , .

+3

All Articles