00001
00032 #ifndef H_TESTCONNECTOR
00033 #define H_TESTCONNECTOR
00034
00035 #include <complex>
00036 #include <iostream>
00037
00038 #ifndef NO_DEPENDENCY_INCLUDES
00039
00040 #include "Connector.h"
00041
00042 #endif
00043
00044 namespace TestConnector
00045 {
00046
00047
00048
00049 template< typename T, size_t Size >
00050 class Zeroes
00051 {
00052 T data_[Size];
00053 public:
00054 Zeroes<T,Size>() { memset( data_, 0, sizeof(data_) ); }
00055 inline operator T*( ) { return data_; }
00056 inline size_t size() const { return Size; }
00057 };
00058
00059
00060
00061
00062 template< class, class B >
00063 class DoesNotProvidePort: public B
00064 {
00065 public:
00066 typedef typename B::PayloadType PayloadType;
00067 };
00068
00069
00071 typedef double data_t;
00072 typedef std::complex< data_t > complex_data_t;
00073
00074
00075 typedef Zeroes< complex_data_t, 1024 > CZ1024;
00076 typedef Zeroes< data_t, 1024 > RZ1024;
00077
00078 template< class P >
00079 class ZeroFilledInputPort:
00080 public Connector::PoliciedConnector<
00081 int,
00082 CZ1024,
00083 Connector::BlitzArrayFromMemoryBuffer< P, CZ1024 >,
00084 DoesNotProvidePort
00085 >
00086 { };
00087
00088
00089
00090
00091
00092
00093 class IostreamOutputPort: public Connector::OutputPort< std::ostream >
00094 {
00095 std::ostream &ios_;
00096 public:
00097 IostreamOutputPort( std::ostream &ios ): ios_( ios ) { }
00098 virtual ~IostreamOutputPort() { }
00099 virtual operator std::ostream&( ) { return ios_; }
00100 };
00101
00102
00103
00104 template< class Key, class Payload >
00105 class TrivialLookupInputPort: public Connector::LookupInputPort< Key, Payload >
00106 {
00107 Payload payload_;
00108 public:
00109 TrivialLookupInputPort<Key,Payload>( const Payload &payload ):
00110 payload_(payload)
00111 { }
00112 virtual ~TrivialLookupInputPort<Key,Payload>() { }
00113
00114
00115 virtual const Payload &operator() ( const Key & ) { return payload_; }
00116 };
00117
00118
00119
00120
00127
00128 template< typename T >
00129 class NoDownstreamCZ1024Connector:
00130 public Connector::PoliciedConnector<
00131 Connector::BlitzArrayFromMemoryBuffer< T, CZ1024 >,
00132 CZ1024,
00133 int,
00134 Connector::AdaptsPayloadForOutput,
00135 DoesNotProvidePort
00136 >
00137 { };
00138
00139 template< typename T >
00140 class NoDownstreamStructConnector:
00141 public Connector::MakesPayloadAvailableForOutput< T,
00142 Connector::SimplePayload< T > >
00143 { };
00144
00145 };
00146
00147 #endif