Main Page | Namespace List | Class Hierarchy | Class List | File List | Related Pages

TestConnector.h

Go to the documentation of this file.
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     // based on FixedMemoryBuffer from ConnectorTest.cc
00048     // a non-resizable vector; might be able to reuse std::vector to do this
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 }; // class Zeroes
00058 
00059 
00060 // a policy preventing us from doing anything upstream
00061 // also could be used as a downstream policy
00062 template< class, class B >
00063 class DoesNotProvidePort: public B
00064 { 
00065 public:
00066     typedef typename B::PayloadType PayloadType;
00067 }; // class DoesNotProvidePort
00068 
00069 
00071 typedef double data_t;
00072 typedef std::complex< data_t > complex_data_t;
00073 
00074 // a test storage array of fixed size which we can put into a connector
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, // not used for much of anything 
00082 CZ1024, // payload type
00083 Connector::BlitzArrayFromMemoryBuffer< P, CZ1024 >,    // inputport payload type: can this be done as const P??
00084 DoesNotProvidePort // upstream policy
00085 >
00086 { };  // class ZeroFilledInputPort
00087 
00088 
00089 
00090 
00091 
00092 // can you make a reference type into a payload.. 
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 }; // class IostreamOutputPort
00101 
00102 
00103 // given an initial case, return only that case, no matter what they key may be
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     // implementation of LookupInputPort<K,P>
00115     virtual const Payload &operator() ( const Key & ) { return payload_; } 
00116 }; // class TrivialLookupInputPort
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 { }; // class NoDownstreamCZ1024Connector
00138 
00139 template< typename T >
00140 class NoDownstreamStructConnector: 
00141 public Connector::MakesPayloadAvailableForOutput< T, 
00142 Connector::SimplePayload< T > >
00143 { }; // class NoDownstreamStructConnector
00144 
00145 }; // namespace TestConnector
00146 
00147 #endif

Generated on Fri Oct 8 12:18:33 2004 for Calibrate.Connector by doxygen 1.3.4