Bug hunting and detection facilities for developers. More...
#include "Err.hxx"
Go to the source code of this file.
Classes | |
class | CLAM::ErrAssertionFailed |
The exception thrown when an assertion fails. More... | |
Namespaces | |
namespace | CLAM |
Defines | |
#define | CLAM_BREAKPOINT {} |
A macro containing break point assembler code for your platform. | |
#define | CLAM_USE_RELEASE_ASSERTS |
#define | CLAM_ABORT(message) |
Macro used when an assert fails. | |
Assertions and checks | |
#define | CLAM_BEGIN_CHECK { |
Marks the start of check code block that is tied to a CLAM_ASSERT and can be removed without affecting any functionality. | |
#define | CLAM_END_CHECK } |
Ends a block of code started by CLAM_BEGIN_CHECK. | |
#define | CLAM_ASSERT(expression, message) |
An assertion is a check on an expression that must be true given that all the contracts are fullfilled. | |
#define | CLAM_WARNING(expression, message) |
#define | CLAM_BEGIN_DEBUG_CHECK { |
Is the same that CLAM_BEGIN_CHECK but for a CLAM_DEBUG_ASSERT instead of a CLAM_ASSERT. | |
#define | CLAM_END_DEBUG_CHECK } |
Ends a block of code started by CLAM_BEGIN_DEBUG_CHECK. | |
#define | CLAM_DEBUG_ASSERT(expression, message) |
#define | CLAM_DEBUG_WARNING(expression, message) |
Typedefs | |
typedef void(* | CLAM::AssertFailedHandlerType )(const char *message, const char *filename, int lineNumber) |
The type of the asserts handlers. | |
typedef void(* | CLAM::WarningHandlerType )(const char *message, const char *filename, int lineNumber) |
The type of the warning handlers. | |
Functions | |
AssertFailedHandlerType | CLAM::SetAssertFailedHandler (AssertFailedHandlerType handler) |
Change the handler function called when an assertion fails. | |
void | CLAM::ExecuteAssertFailedHandler (const char *message, const char *filename, int linenumber) |
(Don't use directly, use the CLAM_ASSERT macro instead) Execute the assert failed handler. | |
WarningHandlerType | CLAM::SetWarningHandler (WarningHandlerType handler) |
Change the handler function called when a warning is given. | |
void | CLAM::ExecuteWarningHandler (const char *message, const char *filename, int linenumber) |
(Don't use directly, use the CLAM_WARNING macro instead) Execute the assert failed handler. |
Bug hunting and detection facilities for developers.
Definition in file Assert.hxx.
#define CLAM_ABORT | ( | message | ) |
do { \ if ( !CLAM::ErrAssertionFailed::breakpointInCLAMAssertEnabled ) { \ throw CLAM::ErrAssertionFailed( message, __FILE__, __LINE__); \ } else { \ CLAM::ExecuteAssertFailedHandler ( message, __FILE__, __LINE__); \ CLAM_BREAKPOINT; \ } \ } while(0)
Macro used when an assert fails.
Definition at line 80 of file Assert.hxx.
#define CLAM_ASSERT | ( | expression, | |||
message | ) |
do { \ if (!(expression)) { \ CLAM_ABORT(message); \ } } while (0)
An assertion is a check on an expression that must be true given that all the contracts are fullfilled.
Notice that this is NOT a regular (documented) check that will throw a (documented) error condition (Err). Asserts on debug mode (when the DEBUG macro is defined) will set a break point while in release mode (DEBUG is not defined) you may get an unexpected exception that can be catched by the application on the top level and do some backups actions. Any way, a descriptive message is displayed.
Sometimes the check is not only an expression but a complete set of statements. In these cases, you can use CLAM_BEGIN_CHECK and CLAM_END_CHECK macros to enclose the whole check code and use CLAM_ASSERT for concrete expressions to check.
You can change the default release mode assertion failed callback by using the SetAssertFailedHandler function.
You can get a lightweight assertion using (with care) the CLAM_DEBUG_ASSERT that is ignored on debug mode. By using the CLAM_DEBUG_ASSERT macro, the final application will not have the possibility of doing an honrous exit (backup data, bug log...) Is worth to keep most of the asserts as CLAM_ASSERT.
Anyway, for very performance depending applications you may use the CLAM_DISABLE_CHECKS to remove ALL the CLAM_ASSERT and CLAM_DEBUG_ASSERT and its related checks in whatever mode you use them.
expression | The expression that must be true. | |
message | A message that describes the unexpected runtime error to the programmer. |
Definition at line 153 of file Assert.hxx.
Referenced by CLAM::DescriptionScope::Add(), CLAM::CircularBuffer< TData >::Add(), CLAM::Factory< AbstractProductType >::Registry::AddCreatorWarningRepetitions(), CLAM::Array< TGuide >::AddElem(), CLAM::SpectralPeakArray::AddIndex(), CLAM::OutControlBase::AddLink(), CLAM::SpectralPeakArray::AddSpectralPeak(), CLAM::Array< TGuide >::Array(), CLAM::Processing::BackendBufferSize(), CLAM::BasicXMLable::BasicXMLable(), CLAM::BPFTmpl< TX, TY >::BPFPolInt(), CLAM::BPFTmpl< TX, TY >::BPFSplineInt(), CLAM::OutPortPublisher< Spectrum >::CanProduce(), CLAM::OutPortPublisher< Spectrum >::CenterEvenRegions(), Simac::ChordSegmentator::changeChordIfSegmentTooSmall(), CLAM::IFFT_base::ChangeSize(), CLAM::BinaryAudioOp< Multiply< TData > >::Check(), CLAM::AbstractAttribute::CheckType(), CLAM::CircularBuffer< TData >::CircularBuffer(), CLAM::DescriptorTmpl< abs >::Compute(), CLAM::SpectralDescriptors::ConcreteCompute(), CLAM::TopLevelProcessing::ConcreteConfigure(), CLAM::SMSAnalysisCore::ConcreteStart(), CLAM::OutPort< Token >::ConnectToConcreteIn(), CLAM::OutPort< Token >::ConnectToIn(), CLAM::ConvertToBPF(), CLAM::Processing::CopyAsConcreteConfig(), CLAM::Array< T >::CopyChunk(), CLAM::BPFTmpl< TX, TY >::CreateSplineTable(), CLAM::List< Frame >::Current(), CLAM::XmlWriteContext::CurrentContext(), CLAM::CircularBuffer< TData >::DecreaseReadIndex(), CLAM::CircularBuffer< TData >::DecreaseWriteIndex(), CLAM::List< T >::DeleteElem(), CLAM::Fundamental::DeleteElem(), CLAM::Array< TGuide >::DeleteElem(), CLAM::SpectralPeakArray::DeleteIndex(), CLAM::SpectralPeakArray::DeleteSpectralPeak(), CLAM::OutPort< Token >::DisconnectFromConcreteIn(), CLAM::OutPortPublisher< Spectrum >::DisconnectFromIn(), CLAM::OutPort< Token >::DisconnectFromIn(), CLAM::AudioCodecs::OggVorbisAudioStream::DiskToMemoryTransfer(), CLAM::WindowGenerator::Do(), CLAM::TopLevelProcessing::Do(), CLAM::SpectrumInterpolator::Do(), CLAM::SpectrumAdder2::Do(), CLAM::SpectralPeakDetect::Do(), CLAM::SpectralPeakArrayAdder::Do(), CLAM::SpectralEnvelopeExtract::Do(), CLAM::SpectralEnvelopeApply::Do(), CLAM::SMSTransformationChainIO::Do(), CLAM::SegmentTransformation::Do(), CLAM::SegmentSMSTimeStretch::Do(), CLAM::SegmentSMSMorph::Do(), CLAM::SegmentSMSHarmonizer::Do(), CLAM::Segmentator::Do(), CLAM::IFFT_ooura::Do(), CLAM::FundFreqDetect::Do(), CLAM::FFT_ooura::Do(), CLAM::FDCombFilter::Do(), CLAM::CleanTracks::Do(), CLAM::CircularShift::Do(), CLAM::List< Frame >::DoNext(), CLAM::List< Frame >::DoPrevious(), CLAM::AudioCodecs::MpegBitstream::EnsureEnoughBufferData(), CLAM::List< T >::Extract(), CLAM::FactoryRegistrator< TheFactoryType, ConcreteProductType >::FactoryRegistrator(), CLAM::XercesDomReadingContext::fetchElement(), CLAM::LibXmlDomReadingContext::fetchElement(), CLAM::XercesDomReadingContext::findElement(), CLAM::LibXmlDomReadingContext::findElement(), CLAM::List< Frame >::First(), CLAM::List< T >::FulfillsInvariant(), CLAM::PhantomBuffer< T >::FulfilsInvariant(), CLAM::MIDI2Melody::GenerateOutputData(), CLAM::Polymorphic< FactoryType >::Get(), CLAM::MatrixTmpl< T >::GetAt(), CLAM::DescriptionScope::GetAttributeName(), CLAM::Audio::GetAudioChunk(), CLAM::Audio::GetAudioSlice(), CLAM::Spectrum::GetBPFSize(), CLAM::OutPortRegistry::GetByNumber(), CLAM::OutControlRegistry::GetByNumber(), CLAM::InPortRegistry::GetByNumber(), CLAM::InControlRegistry::GetByNumber(), CLAM::ReadHook< AttributeType >::GetCurrent(), CLAM::OutPortPublisher< Spectrum >::GetData(), CLAM::MatrixTmpl< T >::GetDet(), CLAM::SpectralPeakArray::GetFirstNonValidIndexPosition(), CLAM::OutPortPublisher< Spectrum >::GetHop(), CLAM::DescriptionScope::GetIndex(), CLAM::MatrixTmpl< T >::GetInverse(), CLAM::Spectrum::GetMag(), CLAM::SpectralPeakArray::GetMaxMagIndex(), SigSlot::Slotv4< ParmType1, ParmType2, ParmType3, ParmType4 >::GetMethod(), SigSlot::Slotv3< ParmType1, ParmType2, ParmType3 >::GetMethod(), SigSlot::Slotv2< ParmType1, ParmType2 >::GetMethod(), SigSlot::Slotv1< ParmType1 >::GetMethod(), CLAM::BPFTmpl< TX, TY >::GetnClosest(), CLAM::NetworkPlayer::GetNetwork(), CLAM::SpectralPeakArray::GetnIndexedPeaks(), CLAM::DescriptionDataPool::GetNumberOfContexts(), CLAM::Spectrum::GetPhase(), CLAM::SpectralPeakArray::GetPositionFromIndex(), CLAM::InPortBase::GetProcessing(), CLAM::ScopePool::GetReadPool(), CLAM::DescriptionDataPool::GetReadPool(), CLAM::Factory< AbstractProductType >::Registry::GetRegisteredNames(), CLAM::DescriptionScheme::GetScope(), CLAM::DescriptionScheme::GetScopeIndex(), CLAM::Spectrum::GetSize(), CLAM::OutPortPublisher< Spectrum >::GetSize(), CLAM::SpectralPeakArray::GetSpectralPeak(), CLAM::Enum::GetString(), CLAM::SpectralPeakArray::GetThruIndexBinPos(), CLAM::SpectralPeakArray::GetThruIndexBinWidth(), CLAM::SpectralPeakArray::GetThruIndexFreq(), CLAM::SpectralPeakArray::GetThruIndexMag(), CLAM::SpectralPeakArray::GetThruIndexPhase(), CLAM::BPFTmpl< TX, TY >::GetValue(), CLAM::DescriptionDataPool::GetWritePool(), CLAM::Array< T >::GiveChunk(), CLAM::Region::Hop(), CLAM::CircularBuffer< TData >::IncreaseReadIndex(), CLAM::CircularBuffer< TData >::IncreaseWriteIndex(), CLAM::SpectralPeakArray::InitIndices(), CLAM::DescriptionDataPool::Insert(), CLAM::XmlWriteContext::InsertAttribute(), CLAM::List< T >::InsertElem(), CLAM::Fundamental::InsertElem(), CLAM::Array< TGuide >::InsertElem(), CLAM::SpectralPeakArray::InsertSpectralPeak(), CLAM::DescriptionDataPool::InstantiateAttribute(), CLAM::MatrixTmpl< T >::Invert(), CLAM::OutPortPublisher< Spectrum >::IsConnectableTo(), CLAM::OutPortPublisher< Spectrum >::IsVisuallyConnectedTo(), CLAM::List< Frame >::Last(), CLAM::ScopePool::LoadFrom(), CLAM::ProcessingDefinitionAdapter::LoadFrom(), CLAM::Condition::NotifyAll(), CLAM::Condition::NotifyOne(), CLAM::NullDomDocumentHandler::NullDomDocumentHandler(), CLAM::NullDomReadingContext::NullDomReadingContext(), CLAM::NullDomWritingContext::NullDomWritingContext(), SigSlot::Slotv4< ParmType1, ParmType2, ParmType3, ParmType4 >::operator()(), SigSlot::Slotv3< ParmType1, ParmType2, ParmType3 >::operator()(), SigSlot::Slotv2< ParmType1, ParmType2 >::operator()(), SigSlot::Slotv1< ParmType1 >::operator()(), CLAM::MatrixTmpl< T >::operator()(), CLAM::SpectralPeakArray::operator+(), CLAM::MatrixTmpl< T >::operator+=(), CLAM::MatrixTmpl< T >::operator-=(), CLAM::Array< TGuide >::operator=(), CLAM::operator>>(), CLAM::Network::PositionOfLastIdentifier(), CLAM::AudioCodecs::PCMAudioStream::PrepareReading(), CLAM::AudioCodecs::OggVorbisAudioStream::PrepareReading(), CLAM::AudioCodecs::PCMAudioStream::PrepareWriting(), CLAM::AudioCodecs::OggVorbisAudioStream::PrepareWriting(), CLAM::InPortPublisher< TData >::PublishInPort(), CLAM::OutPortPublisher< Spectrum >::PublishOutPort(), CLAM::XercesDomReader::read(), CLAM::LibXmlDomReader::read(), CLAM::CircularBuffer< TData >::Read(), CLAM::RecursiveMutex::RecursiveMutex(), CLAM::DescriptionDataPool::Remove(), CLAM::OutControlBase::RemoveLink(), CLAM::WritingRegion< Token, DataStructure >::RemoveRegion(), CLAM::SpectralPeakArray::ResetIndices(), CLAM::PhantomBuffer< T >::Resize(), CLAM::ControlArray< ControlT >::Resize(), CLAM::Array< TGuide >::Resize(), CLAM::LinearMapping::Set(), CLAM::NoteToFreqMapping::Set(), CLAM::ValueToRatioMapping::Set(), CLAM::SpectralSynthesisConfig::SetAnalWindowSize(), CLAM::SMSSynthesisConfig::SetAnalWindowSize(), CLAM::MatrixTmpl< T >::SetAt(), CLAM::Audio::SetAudioChunk(), CLAM::AudioSource::SetFrameAndHopSize(), CLAM::AudioSink::SetFrameAndHopSize(), CLAM::AudioBufferSource::SetFrameAndHopSize(), CLAM::AudioBufferSink::SetFrameAndHopSize(), CLAM::OutPortPublisher< Spectrum >::SetHop(), CLAM::SpectralPeakArray::SetIndicesTo(), CLAM::CircularBuffer< TData >::SetInitialReadOffset(), CLAM::CircularBuffer< TData >::SetInitialWriteOffset(), CLAM::BPFTmpl< TX, TY >::SetIntpType(), CLAM::SpectrumInterpolator::SetPrototypes(), CLAM::SpectrumAdder2::SetPrototypes(), CLAM::IFFT_ooura::SetPrototypes(), CLAM::SpectralPeakDescriptors::SetpSpectralPeakArray(), CLAM::SpectralDescriptors::SetpSpectrum(), CLAM::Array< TGuide >::SetPtr(), CLAM::RulerTicks::setRange(), CLAM::CircularBuffer< TData >::SetReadSize(), CLAM::OutPortPublisher< Spectrum >::SetSize(), CLAM::Audio::SetSize(), CLAM::Array< TGuide >::SetSize(), CLAM::SpectralPeakArray::SetSpectralPeak(), CLAM::SpectralSynthesisConfig::SetSynthWindowSize(), CLAM::SMSSynthesisConfig::SetSynthWindowSize(), CLAM::SpectralPeakArray::SetThruIndexBinPos(), CLAM::SpectralPeakArray::SetThruIndexBinWidth(), CLAM::SpectralPeakArray::SetThruIndexFreq(), CLAM::SpectralPeakArray::SetThruIndexMag(), CLAM::SpectralPeakArray::SetThruIndexPhase(), CLAM::SpectralPeakArray::SetThruIndexSpectralPeak(), CLAM::Enum::SetValue(), CLAM::RulerTicks::setWidth(), CLAM::SpectralAnalysisConfig::SetWindowSize(), CLAM::CircularBuffer< TData >::SetWriteSize(), CLAM::ControlArray< ControlT >::Shrink(), CLAM::SpectralDescriptors::SpectralDescriptors(), CLAM::SpectralPeakDescriptors::SpectralPeakDescriptors(), CLAM::Thread::Start(), CLAM::StatsTmpl< false, FrameDescriptors, FrameDescriptors >::StatsTmpl(), CLAM::TabFunct< OriginalFunction >::TabFunct(), CLAM::OutPort< Token >::TryDisconnectFromConcreteIn(), CLAM::OutPort< Token >::TryDisconnectFromPublisher(), CLAM::SpectrumSubstracter2::UnsetPrototypes(), CLAM::SpectrumAdder::UnsetPrototypes(), CLAM::IFFT_fftw3::UnsetPrototypes(), CLAM::SegmentTransformation::WrapFrameTransformation(), CLAM::CircularBuffer< TData >::Write(), CLAM::XMLComponentAdapter::XMLComponentAdapter(), CLAM::Attribute< AttributeType >::XmlRestoreData(), CLAM::XmlWriteContext::XmlWriteContext(), CLAM::Thread::Yield(), CLAM::RangeView::zoom(), and CLAM::Condition::~Condition().
#define CLAM_BEGIN_CHECK { |
Marks the start of check code block that is tied to a CLAM_ASSERT and can be removed without affecting any functionality.
You must use it on the same sense that CLAM_ASSERT is used.
Definition at line 151 of file Assert.hxx.
Referenced by CLAM::BasicXMLable::BasicXMLable(), CLAM::Spectrum::GetBPFSize(), and CLAM::Spectrum::GetSize().
#define CLAM_BEGIN_DEBUG_CHECK { |
Is the same that CLAM_BEGIN_CHECK but for a CLAM_DEBUG_ASSERT instead of a CLAM_ASSERT.
Definition at line 186 of file Assert.hxx.
Referenced by CLAM::Processing::AbleToExecute(), and CLAM::Enum::SetValue().
#define CLAM_BREAKPOINT {} |
A macro containing break point assembler code for your platform.
If you platform is not being considered by the header you will get an warning message when compiling.
Definition at line 64 of file Assert.hxx.
#define CLAM_DEBUG_ASSERT | ( | expression, | |||
message | ) |
do { \ if (!(expression)) { \ CLAM_ABORT(message); \ } } while (0)
Definition at line 188 of file Assert.hxx.
Referenced by CLAM::Processing::AbleToExecute(), CLAM::List< T >::AddElem(), CLAM::Fundamental::AddElem(), CLAM::WritingRegion< Token, DataStructure >::CanProduce(), CLAM::MIDIManager::Check(), CLAM::OutPortPublisher< Spectrum >::ConnectToIn(), CLAM::ReadingRegion< WritingRegion >::Consume(), CLAM::List< Frame >::Current(), CLAM::List< T >::DeleteElem(), CLAM::Fundamental::DeleteElem(), CLAM::InPortBase::Disconnect(), CLAM::OutPortPublisher< Spectrum >::DisconnectFromAll(), CLAM::OutPort< Token >::DisconnectFromConcreteIn(), CLAM::SynthSineSpectrum::Do(), CLAM::SpectrumInterpolator::Do(), CLAM::SpectrumAdder2::Do(), CLAM::SpectralPeakArrayInterpolator::Do(), CLAM::SpectralPeakArrayAdder::Do(), CLAM::SMSAnalysisCore::Do(), CLAM::Segmentator::Do(), CLAM::IFFT_ooura::Do(), CLAM::FrameInterpolator::Do(), CLAM::FrameAdder::Do(), CLAM::FFT_ooura::Do(), CLAM::List< T >::Extract(), CLAM::List< Frame >::First(), CLAM::Fundamental::GetErr(), CLAM::Fundamental::GetFreq(), CLAM::OutPort< Token >::GetLastWrittenData(), CLAM::DynamicType::InformAll(), CLAM::List< T >::InsertElem(), CLAM::Fundamental::InsertElem(), CLAM::List< Frame >::Last(), CLAM::List< Frame >::List(), CLAM::AudioCodecs::PCMAudioStream::MemoryToDiskTransfer(), CLAM::StreamImpl< Token, PhantomBuffer >::NewReadingRegionSize(), CLAM::StreamImpl< Token, PhantomBuffer >::NewWritingRegionSize(), CLAM::TabFunct< OriginalFunction >::operator()(), CLAM::CentralMoment< 4, abs, TData, TData >::operator()(), CLAM::WritingRegion< Token, DataStructure >::operator[](), CLAM::StreamImpl< Token, PhantomBuffer >::operator[](), CLAM::StreamImpl< Token, DataStructure >::operator[](), CLAM::ReadingRegion< WritingRegion >::operator[](), CLAM::List< T >::operator[](), CLAM::Array< TGuide >::operator[](), CLAM::WritingRegion< Token, DataStructure >::Produce(), CLAM::PhantomBuffer< T >::Read(), CLAM::Array< TGuide >::SetElem(), CLAM::Fundamental::SetErr(), CLAM::Fundamental::SetFreq(), CLAM::WindowGenerator::SetSize(), CLAM::PhantomBuffer< T >::Touch(), CLAM::InPort< Token >::UnAttachRegion(), and CLAM::PhantomBuffer< T >::Write().
#define CLAM_DEBUG_WARNING | ( | expression, | |||
message | ) |
do { \ if (!(expression)) { \ CLAM::ExecuteWarningHandler ( message, __FILE__, __LINE__); \ } } while (0)
Definition at line 193 of file Assert.hxx.
#define CLAM_END_CHECK } |
Ends a block of code started by CLAM_BEGIN_CHECK.
Definition at line 152 of file Assert.hxx.
Referenced by CLAM::BasicXMLable::BasicXMLable(), CLAM::Spectrum::GetBPFSize(), and CLAM::Spectrum::GetSize().
#define CLAM_END_DEBUG_CHECK } |
Ends a block of code started by CLAM_BEGIN_DEBUG_CHECK.
Definition at line 187 of file Assert.hxx.
Referenced by CLAM::Processing::AbleToExecute(), and CLAM::Enum::SetValue().
#define CLAM_USE_RELEASE_ASSERTS |
Definition at line 69 of file Assert.hxx.
#define CLAM_WARNING | ( | expression, | |||
message | ) |
do { \ if (!(expression)) { \ CLAM::ExecuteWarningHandler ( message, __FILE__, __LINE__); \ } } while (0)
Definition at line 158 of file Assert.hxx.
Referenced by CLAM::XmlStorage::AppendToDocument(), CLAM::Audio::SetDuration(), and CLAM::Audio::SetEndTime().