Technology
 

Pipes

From Indus Communities

The Pipes style of composition uses the pipe ( -> ) operator representing the connector to implement the following composition rules

  • SourceName -> HandlerName -> SinkName
  • SourceName -> SinkName
  • SourceName -> HandlerName

The last Composition rule returns back a variable with either a value or object reference. In such case, the return value can be stored into a variable of the return type of the port.

This return value can also be used for conditional checking

if((SourceName-> HandlerName) > 100){
		/* logic */
	}
Component PipeTester{

	Source Src = void GetVal( ); // won't work as return type is void
	Source Src = private int GetVal( ); 
          // does modifier work ? No. All ports are implicitly public
	Source Src = int GetNum(int input); 
          // does source take input ? No. Source port only returns value
	Source Src = int GetNum( );

	Handler Hnd = int SumUp( ); 
          //does Handler compulsorily need an input ? Yes.
	Handler Hnd = void SumUp(int number); 
          //will it work if return type is void ? No.
	Handler Hnd = protected int SumUp(int number); 
          //does modifier work ? No.
	Handler Hnd = int SumUp(int number);

	Sink Snk = int PutVal( ); //won't work since Sink can not return value
	Sink Snk = public void PutVal(int finalnum); //does modifier work ? No.
	Sink Snk = void PutVal(int finalnum);

}

Use of Ports in Component definitions : PipeTester.indus


Next : Pipes & Filters test case (covers negative tests also)


Next : A better example of Pipes