csp::AltChanin< DATA_TYPE > Class Template Reference
[Channel Ends]

List of all members.

Detailed Description

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

This class is identical to Chanin except that it also supports ALTing.

See the page on Channel Ends and the section on Channels in the guide.

C++CSP v1.x Compatibility:

See the note in the Channel Ends module

See also:
One2OneChannel::reader()

Any2OneChannel::reader()

BufferedOne2OneChannel::reader()

BufferedAny2OneChannel::reader()

Chanin

Chanout

PoisonException


Public Types

typedef ScopedExtInput< DATA_TYPE > ScopedExtInput
 A typedef for the ScopedExtInput.

Public Member Functions

 AltChanin ()
 A constructor for instances that are class members.
 AltChanin (const AltChanin< DATA_TYPE > &cho)
 A standard copy constructor.
void checkPoison () const
 Checks the channel for poison.
void extInput (DATA_TYPE *const dest, void(*function)()) const
 DEPRECATED; Performs an extended input.
template<class PROCESS>
void extInput (DATA_TYPE *const dest, PROCESS *proc, void(PROCESS::*memberFn)()) const
 DEPRECATED; A syntax for performing an extended input.
void input (DATA_TYPE *const dest) const
 Performs a normal input.
GuardinputGuard () const
 Gets an input guard to use in an ALT.
 operator Chanin () const
 Returns a copy with the Alt capability hidden.
bool operator== (const csp::AltChanin< DATA_TYPE > &b) const
 To allow sets of channel ends that are able to keep only one end per channel we define relational operators Note that a non-poisonable channel end is not equal to a poisonable channel end of the same channel.
const AltChanin< DATA_TYPE > & operator>> (DATA_TYPE &obj) const
 Performs a normal input.
bool pending () const
 Checks whether an input would finish immediately on the channel.
void poison () const
 Poisons the channel.
void read (DATA_TYPE *const dest) const
 Identical to the input method.


Member Typedef Documentation

template<typename DATA_TYPE>
typedef ScopedExtInput<DATA_TYPE> csp::AltChanin< DATA_TYPE >::ScopedExtInput

A typedef for the ScopedExtInput.

Chanin<DATA_TYPE>::ScopedExtInput is equivalent to ScopedExtInput<DATA_TYPE>


Constructor & Destructor Documentation

template<typename DATA_TYPE>
csp::AltChanin< DATA_TYPE >::AltChanin ( const AltChanin< DATA_TYPE > &  cho  )  [inline]

A standard copy constructor.

template<typename DATA_TYPE>
csp::AltChanin< DATA_TYPE >::AltChanin (  )  [inline]

A constructor for instances that are class members.

Do not use this constructor for constructing channel ends, instead use something like this:

                Chanin<int> chanin = somechannel.reader();
This constructor is provided because, as can be seen in the Delta common process, sometimes channel ends need to be class members but they cannot be initialised until the body of the constructor (rather than the initialiser list) so this default constructor is provided for that mode of use.


Member Function Documentation

template<typename DATA_TYPE>
csp::AltChanin< DATA_TYPE >::operator Chanin (  )  const [inline]

Returns a copy with the Alt capability hidden.

This is useful for passing the channel end to processes that do not need the ALTing capability

template<typename DATA_TYPE>
Guard* csp::AltChanin< DATA_TYPE >::inputGuard (  )  const [inline]

Gets an input guard to use in an ALT.

The guard will be ready when either there is data to be read, or the channel is poisoned. If an input guard for a channel is selected by the Alternative, you must then perform an input or extended input on the channel as your next action.

The Alternative class will delete this Guard, so you don't have to

C++CSP v1.x Compatibility

This method has been changed since C++CSP v1.x. In v1.x, the inputGuard method took a parameter that specified where to store the result of the input; the Alternative would then perform the input automatically if that guard was selected, so after the select method returned there was no need to perform the input.

The JCSP method has now been adopted. If the guard is selected by the Alternative, it is now up to the user to then perform the input from the channel manually. However, this gives the added flexibility of having a custom try-catch block for poison, or the use of the new ScopedExtInput class for an in-place extended input.

See also:
Alternative
Returns:
The input guard

template<typename DATA_TYPE>
const AltChanin<DATA_TYPE>& csp::AltChanin< DATA_TYPE >::operator>> ( DATA_TYPE &  obj  )  const [inline]

Performs a normal input.

Does the same as the input() function but takes a reference not a pointer. It can be used to easily chain sequential inputs as follows:

                One2OneChannel<int> chan;
                AltChanin<int> in = chan.reader();
                int a,b;

                //This:
                in.input(&a);in.input(&b);

                //Is the same as this:
                in >> a >> b;

Parameters:
obj The variable to input into
Returns:
This channel, for chaining inputs

template<typename DATA_TYPE>
bool csp::AltChanin< DATA_TYPE >::pending (  )  const [inline]

Checks whether an input would finish immediately on the channel.

This is used as a short form of polling a channel (that would otherwise have to be done using a PRI ALT with a skip guard)

In practical terms, this method will return true if any of the following are true:

Returns:
Whether an input would finish immediately on this channel

template<typename DATA_TYPE>
void csp::AltChanin< DATA_TYPE >::input ( DATA_TYPE *const   dest  )  const [inline]

Performs a normal input.

This simply performs a normal input on the channel, into dest It will not return until the input has completed

Parameters:
dest The destination of the input. Must not be NULL

template<typename DATA_TYPE>
void csp::AltChanin< DATA_TYPE >::read ( DATA_TYPE *const   dest  )  const [inline]

Identical to the input method.

See also:
input()

template<typename DATA_TYPE>
void csp::AltChanin< DATA_TYPE >::poison (  )  const [inline]

Poisons the channel.

This poisons the channel, and can be safely called multiple times

Read about PoisonException for more information regarding poison

See also:
PoisonException

checkPoison()

template<typename DATA_TYPE>
void csp::AltChanin< DATA_TYPE >::checkPoison (  )  const [inline]

Checks the channel for poison.

Rather than being an accessor for the poison flag, this function instead checks it and then returns normally if the channel is not poisoned, or throws a PoisonException if it is.

This function allows processes performing lots of calculations and no channel communications to check for poison more often than only checking when a channel communication is performed

See also:
PoisonException

poison()

template<typename DATA_TYPE>
bool csp::AltChanin< DATA_TYPE >::operator== ( const csp::AltChanin< DATA_TYPE > &  b  )  const [inline]

To allow sets of channel ends that are able to keep only one end per channel we define relational operators Note that a non-poisonable channel end is not equal to a poisonable channel end of the same channel.

template<typename DATA_TYPE>
template<class PROCESS>
void csp::AltChanin< DATA_TYPE >::extInput ( DATA_TYPE *const   dest,
PROCESS *  proc,
void(PROCESS::*)()  memberFn 
) const [inline]

DEPRECATED; A syntax for performing an extended input.

This function takes a destination for the extended input, a class type - which will usually be a process, though it can be any class - and a member function of that class (which should be accessible by Chanin).

The input will be performed, then the function will be called then the outputter will be freed.

You may well wish to look at ScopedExtInput for an alternative way of performing extended inputs.

Parameters:
dest The destination for the extended input. Must not be NULL
proc The class (not necessarily a process) to call memberFn for
memberFn The member function of proc to call
See also:
ScopedExtInput
Deprecated:

template<typename DATA_TYPE>
void csp::AltChanin< DATA_TYPE >::extInput ( DATA_TYPE *const   dest,
void(*)()  function 
) const [inline]

DEPRECATED; Performs an extended input.

This function inputs to dest, then calls function() then frees the outputter. You may well wish to look at ScopedExtInput for an alternative way of performing extended inputs

Parameters:
dest The destination for the extended input. Must not be NULL
function The function to call during the extended input
See also:
ScopedExtInput
Deprecated:


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