csp::ChannelBufferFactory< DATA_TYPE > Class Template Reference
[Channel Buffers]

Inheritance diagram for csp::ChannelBufferFactory< DATA_TYPE >:

csp::ChannelBufferFactoryImpl< DATA_TYPE, BUFFER_TYPE > csp::SizedChannelBufferFactoryImpl< DATA_TYPE, BUFFER_TYPE > List of all members.

Detailed Description

template<typename DATA_TYPE>
class csp::ChannelBufferFactory< DATA_TYPE >

The base class for all the channel buffer factories.

Use this class if you want your process to use a channel buffer factory provided from outside your process, for example:

        class BufferedPingPong : public CSProcess
        {
        private:
            ChannelBufferFactory<DATA_TYPE>* factory;
        protected:
            void run()
            {
                BufferedOne2OneChannel c(factory), d(factory);
                
                Run(InParallel
                    (new Prefix<int>(d.reader(),c.writer(),0))
                    (new Id<int>(c.reader(),d.writer())
                );
            }
        public:
            inline explicit BufferedPingPong(ChannelBufferFactory<DATA_TYPE>* _factory)
                :   factory(_factory)
            {
            }
        };

If you create a new ChannelBuffer, you will need to implement a factory for it. To do this, you may find the ChannelBufferFactoryImpl and SizedChannelBufferFactoryImpl classes useful

For more information, see the page on Channel Buffers and the section in the guide on Buffered Channels.


Public Member Functions

virtual ChannelBuffer< DATA_TYPE > * createBuffer () const =0
 Creates a new channel buffer.


Member Function Documentation

template<typename DATA_TYPE>
virtual ChannelBuffer<DATA_TYPE>* csp::ChannelBufferFactory< DATA_TYPE >::createBuffer (  )  const [pure virtual]

Creates a new channel buffer.

The returned channel buffer will be deleted by the channel using it, so it should be allocated using new (that is, allocated on the heap), and a pointer to it should not need to be retained by the factory.

Note that the method is const, this is important to remember when implementing a channel factory.

Returns:
A new channel buffer

Implemented in csp::ChannelBufferFactoryImpl< DATA_TYPE, BUFFER_TYPE >, and csp::SizedChannelBufferFactoryImpl< DATA_TYPE, BUFFER_TYPE >.


Generated on Mon Aug 20 12:24:28 2007 for C++CSP2 by  doxygen 1.4.7