CLAM::PortMonitor< TheDataType, ThePortType > Class Template Reference

A processing that allows other (GUI) thread to monitor a port in a thread safe way. More...

#include <PortMonitor.hxx>

List of all members.

Public Types

typedef TheDataType DataType
typedef ThePortType PortType

Public Member Functions

 PortMonitor (const Config &cfg=Config())
virtual ~PortMonitor ()
bool Do ()
 Supervised mode execution method (using ports).
const char * GetClassName () const
 Override it in every subclass and retur the name of that class.
const DataTypeFreezeAndGetData ()
void UnfreezeData ()
void AttachStartSlot (SigSlot::Slotv0 &slot)
void AttachStopSlot (SigSlot::Slotv0 &slot)
void AttachSlotNewData (SigSlot::Slotv0 &slot)
template<>
bool Do ()
 Supervised mode execution method (using ports).
template<>
 PortMonitor (const Config &cfg)
template<>
bool Do ()
 Supervised mode execution method (using ports).
template<>
 PortMonitor (const Config &cfg)

Protected Member Functions

bool ConcreteStart ()
 Processing objects have to redefine this method when starting them implies some internal changes.
bool ConcreteStop ()
 Processing objects have to redefine this method when stoping them implies some internal changes.

Detailed Description

template<typename TheDataType, typename ThePortType = InPort<TheDataType>>
class CLAM::PortMonitor< TheDataType, ThePortType >

A processing that allows other (GUI) thread to monitor a port in a thread safe way.

Subclass specializations of this template in order to use it.

 class SpectrumPortMonitor : public CLAM::PortMonitor<CLAM::Spectrum>
 {
        public:
        const char * GetClassName() const {return "SpectrumPortMonitor";}
 };

In order to get data from a GUI thread you should use a PortMonitor::DataLocker

 // Supose 'monitor' being a SpectrumPortMonitor reference.
 ...
 {
        const Spectrum & spectrum = monitor.FreezeAndGetData();
        // The monitor won't overwrite the current copy until Release.
        
        // Do what ever with the object

        visualize(spectrum);
        
        monitor.UnfreezeData();
        // After unfreezing, 'spectrum' is not safe to use.
        // and the monitor will be allowed to swap copies
 }

Definition at line 53 of file PortMonitor.hxx.


Member Typedef Documentation

template<typename TheDataType, typename ThePortType = InPort<TheDataType>>
typedef TheDataType CLAM::PortMonitor< TheDataType, ThePortType >::DataType

Definition at line 56 of file PortMonitor.hxx.

template<typename TheDataType, typename ThePortType = InPort<TheDataType>>
typedef ThePortType CLAM::PortMonitor< TheDataType, ThePortType >::PortType

Definition at line 57 of file PortMonitor.hxx.


Constructor & Destructor Documentation

template<typename PortDataType , typename PortType >
CLAM::PortMonitor< PortDataType, PortType >::PortMonitor ( const Config cfg = Config()  )  [inline]

Definition at line 103 of file PortMonitor.hxx.

References CLAM::Processing::Configure(), and CLAM::Hidden::initData().

template<typename PortDataType , typename PortType >
CLAM::PortMonitor< PortDataType, PortType >::~PortMonitor (  )  [inline, virtual]

Definition at line 113 of file PortMonitor.hxx.

template<>
CLAM::PortMonitor< Audio, AudioInPort >::PortMonitor ( const Config cfg  )  [inline]

Definition at line 21 of file PortMonitor.cxx.

template<>
CLAM::PortMonitor< Audio, AudioInPort >::PortMonitor ( const Config cfg  )  [inline]

Member Function Documentation

template<typename TheDataType, typename ThePortType = InPort<TheDataType>>
void CLAM::PortMonitor< TheDataType, ThePortType >::AttachSlotNewData ( SigSlot::Slotv0 slot  )  [inline]

Definition at line 71 of file PortMonitor.hxx.

template<typename TheDataType, typename ThePortType = InPort<TheDataType>>
void CLAM::PortMonitor< TheDataType, ThePortType >::AttachStartSlot ( SigSlot::Slotv0 slot  )  [inline]

Definition at line 69 of file PortMonitor.hxx.

template<typename TheDataType, typename ThePortType = InPort<TheDataType>>
void CLAM::PortMonitor< TheDataType, ThePortType >::AttachStopSlot ( SigSlot::Slotv0 slot  )  [inline]

Definition at line 70 of file PortMonitor.hxx.

template<typename TheDataType, typename ThePortType = InPort<TheDataType>>
bool CLAM::PortMonitor< TheDataType, ThePortType >::ConcreteStart ( void   )  [inline, protected, virtual]

Processing objects have to redefine this method when starting them implies some internal changes.

ie: adquiring resources.

Returns:
Whether start changes have been successful

Reimplemented from CLAM::Processing.

Definition at line 74 of file PortMonitor.hxx.

template<typename TheDataType, typename ThePortType = InPort<TheDataType>>
bool CLAM::PortMonitor< TheDataType, ThePortType >::ConcreteStop (  )  [inline, protected, virtual]

Processing objects have to redefine this method when stoping them implies some internal changes.

ie: releasing resources.

Returns:
Whether stop changes have been successful

Reimplemented from CLAM::Processing.

Definition at line 75 of file PortMonitor.hxx.

template<>
bool CLAM::PortMonitor< Audio, AudioInPort >::Do (  )  [inline, virtual]

Supervised mode execution method (using ports).

Returns:
A boolean telling whether it has been output

Implements CLAM::Processing.

template<>
bool CLAM::PortMonitor< Audio, AudioInPort >::Do (  )  [inline, virtual]

Supervised mode execution method (using ports).

Returns:
A boolean telling whether it has been output

Implements CLAM::Processing.

Definition at line 5 of file PortMonitor.cxx.

References CLAM::PortMonitor< TheDataType, ThePortType >::Do(), and CLAM::Hidden::ScopedTryLock< TryMutexType >::Locked().

template<typename PortDataType , typename PortType >
bool CLAM::PortMonitor< PortDataType, PortType >::Do (  )  [inline, virtual]

Supervised mode execution method (using ports).

Returns:
A boolean telling whether it has been output

Implements CLAM::Processing.

Definition at line 131 of file PortMonitor.hxx.

References CLAM::Processing::AbleToExecute(), SigSlot::Signalv0::Emit(), and CLAM::Hidden::ScopedTryLock< TryMutexType >::Locked().

Referenced by CLAM::PortMonitor< TheDataType, ThePortType >::Do().

template<typename PortDataType , typename PortType >
const PortMonitor< PortDataType, PortType >::DataType & CLAM::PortMonitor< PortDataType, PortType >::FreezeAndGetData (  )  [inline]

Definition at line 118 of file PortMonitor.hxx.

template<typename TheDataType, typename ThePortType = InPort<TheDataType>>
const char* CLAM::PortMonitor< TheDataType, ThePortType >::GetClassName (  )  const [inline, virtual]
template<typename PortDataType , typename PortType >
void CLAM::PortMonitor< PortDataType, PortType >::UnfreezeData (  )  [inline]

Definition at line 125 of file PortMonitor.hxx.


The documentation for this class was generated from the following file:
Generated by  doxygen 1.6.3