hydrogen 1.2.3
Base Class Reference

Base class. More...

#include <Object.h>

Inheritance diagram for Base:
Object< AboutDialogContributorList > Object< Action > Object< AudioEngineInfoForm > Object< AudioFileBrowser > Object< AutomationPathView > Object< Button > Object< ClickableLabel > Object< ColorSelectionButton > Object< CommonStrings > Object< ComponentMixerLine > Object< CpuLoadWidget > Object< DetailWaveDisplay > Object< Director > Object< Download > Object< ExportMidiDialog > Object< ExportSongDialog > Object< Fader > Object< FileBrowser > Object< FileDialog > Object< FilesystemInfoForm > Object< ADSR > Object< AlsaAudioDriver > Object< AlsaMidiDriver > Object< AudioEngine > Object< AudioEngineTests > Object< AudioOutput > Object< AutomationPath > Object< AutomationPathSerializer > Object< ColorTheme > Object< CoreActionController > Object< CoreAudioDriver > Object< CoreMidiDriver > Object< DiskWriterDriver > Object< Drumkit > Object< DrumkitComponent > Object< Effects > Object< EnvelopePoint > Object< EventQueue > Object< FakeDriver > Object< Files > Object< Filesystem > Object< FontTheme > Object< Future > Object< Hydrogen > Object< Instrument > Object< InstrumentComponent > Object< InstrumentLayer > Object< InstrumentList > Object< InterfaceTheme > Object< JackAudioDriver > Object< JackMidiDriver > Object< LadspaControlPort > Object< LadspaFX > Object< LadspaFXGroup > Object< LadspaFXInfo > Object< Legacy > Object< License > Object< MidiInput > Object< MidiOutput > Object< Note > Object< NullDriver > Object< OssDriver > Object< Pattern > Object< PatternList > Object< Playlist > Object< PortAudioDriver > Object< PortMidiDriver > Object< Preferences > Object< PulseAudioDriver > Object< Random > Object< SMF > Object< SMF0Writer > Object< SMF1Writer > Object< SMF1WriterMulti > Object< SMF1WriterSingle > Object< SMFBuffer > Object< SMFCopyRightNoticeMetaEvent > Object< SMFEvent > Object< SMFHeader > Object< SMFNoteOffEvent > Object< SMFNoteOnEvent > Object< SMFSetTempoMetaEvent > Object< SMFTimeSignatureMetaEvent > Object< SMFTrack > Object< SMFTrackNameMetaEvent > Object< SMFWriter > Object< Sample > Object< Sampler > Object< Song > Object< SongEditorPanelBpmWidget > Object< SongEditorPanelTagWidget > Object< SoundLibraryDatabase > Object< SoundLibraryInfo > Object< SoundLibraryPropertiesDialog > Object< Synth > Object< Theme > Object< Timeline > Object< Translations > Object< TransportPosition > Object< WindowProperties > Object< XMLDoc > Object< XMLNode > Object< HydrogenApp > Object< InfoBar > Object< InstrumentEditor > Object< InstrumentEditorPanel > Object< InstrumentNameWidget > Object< InstrumentRack > Object< LCDCombo > Object< LCDDisplay > Object< LCDSpinBox > Object< LED > Object< LadspaFXMixerLine > Object< LadspaFXProperties > Object< LadspaFXSelector > Object< LayerPreview > Object< MainForm > Object< MainSampleWaveDisplay > Object< MasterMixerLine > Object< MetronomeLED > Object< MidiActionManager > Object< MidiMap > Object< MidiSenseWidget > Object< MidiTable > Object< Mixer > Object< MixerLine > Object< MixerSettingsDialog > Object< NsmClient > Object< OscServer > Object< PatternEditor > Object< PatternEditorInstrumentList > Object< PatternEditorPanel > Object< PatternEditorRuler > Object< PatternFillDialog > Object< PianoRollEditor > Object< PixmapWidget > Object< PlayerControl > Object< PlaylistDialog > Object< PreferencesDialog > Object< Rotary > Object< SampleEditor > Object< SampleWaveDisplay > Object< SongEditor > Object< SongEditorPanel > Object< SongEditorPatternList > Object< SongEditorPositionRuler > Object< SoundLibraryExportDialog > Object< SoundLibraryImportDialog > Object< SoundLibraryOpenDialog > Object< SoundLibraryPanel > Object< SoundLibraryRepositoryDialog > Object< SoundLibraryTree > Object< SplashScreen > Object< StatusMessageDisplay > Object< TargetWaveDisplay > Object< VirtualPatternDialog > Object< WaveDisplay > Object< T >

Public Member Functions

 Base ()
 
 Base (const Base &other)
 
virtual const char * class_name () const
 
void Print (bool bShort=true) const
 Prints content of toQString() via DEBUGLOG.
 
virtual QString toQString (const QString &sPrefix="", bool bShort=true) const
 Formatted string version for debugging purposes.
 

Static Public Member Functions

static const char * _class_name ()
 return the class name
 
static QString base_clock (const QString &sMsg)
 Measures the current time and stores it in __last_clock.
 
static QString base_clock_in (const QString &sMsg)
 
static int bootstrap (Logger *logger, bool count=false)
 must be called before any Object instantiation !
 
static bool count_active ()
 
static int getAliveObjectCount ()
 
static object_map_t getObjectMap ()
 
static Loggerlogger ()
 return the logger instance
 
static int objects_count ()
 
static void printObjectMapDiff (object_map_t map)
 Creates the difference between a snapshot of the object map and its current state and prints it to std::cout.
 
static void set_count (bool flag)
 enable/disable class instances counting
 
static void write_objects_map_to (std::ostream &out, object_map_t *map=nullptr)
 output the full objects map to a given ostream
 
static void write_objects_map_to_cerr ()
 output objects map to stderr
 

Static Public Attributes

static QString sPrintIndention = " "
 String used to format the debugging string output of some core classes.
 

Protected Member Functions

 ~Base ()
 

Static Protected Member Functions

static void registerClass (const char *name, const atomic_obj_cpt_t *counters)
 

Static Protected Attributes

static bool __count = false
 should we count class instances
 
static timeval __last_clock = { 0, 0 }
 
static Logger__logger = nullptr
 

Static Private Attributes

static pthread_mutex_t __mutex
 yeah this has to be thread safe
 
static std::atomic< int > __objects_count
 total objects count
 
static object_internal_map_t __objects_map
 objects classes and instances count structure
 

Detailed Description

Base class.

Definition at line 62 of file Object.h.

Constructor & Destructor Documentation

◆ Base() [1/2]

Base ( )
inline

Definition at line 64 of file Object.h.

◆ Base() [2/2]

Base ( const Base & other)
inline

Definition at line 71 of file Object.h.

◆ ~Base()

~Base ( )
inlineprotected

Definition at line 146 of file Object.h.

Member Function Documentation

◆ _class_name()

static const char * _class_name ( )
inlinestatic

return the class name

Definition at line 78 of file Object.h.

◆ base_clock()

QString base_clock ( const QString & sMsg)
static

Measures the current time and stores it in __last_clock.

In case __last_clock was already set - base_clock() was invoked at least once - the time difference will be logged with DEBUG level.

Definition at line 195 of file Object.cpp.

◆ base_clock_in()

QString base_clock_in ( const QString & sMsg)
static

Definition at line 181 of file Object.cpp.

◆ bootstrap()

int bootstrap ( Logger * logger,
bool count = false )
static

must be called before any Object instantiation !

Parameters
loggerthe logger instance used to send messages to
countshould we count objects instances or not

Definition at line 61 of file Object.cpp.

◆ class_name()

virtual const char * class_name ( ) const
inlinevirtual

Definition at line 79 of file Object.h.

◆ count_active()

static bool count_active ( )
inlinestatic

Definition at line 85 of file Object.h.

◆ getAliveObjectCount()

int getAliveObjectCount ( )
static
Returns
Total numbers of objects being alive.

Definition at line 125 of file Object.cpp.

◆ getObjectMap()

object_map_t getObjectMap ( )
static
Returns
Copy of the object map.

Definition at line 140 of file Object.cpp.

◆ logger()

static Logger * logger ( )
inlinestatic

return the logger instance

Definition at line 103 of file Object.h.

◆ objects_count()

static int objects_count ( )
inlinestatic

Definition at line 86 of file Object.h.

◆ Print()

void Print ( bool bShort = true) const

Prints content of toQString() via DEBUGLOG.

Parameters
bShortWhether to display the content of the member class variables and to use line breaks.

Definition at line 177 of file Object.cpp.

◆ printObjectMapDiff()

void printObjectMapDiff ( object_map_t map)
static

Creates the difference between a snapshot of the object map and its current state and prints it to std::cout.

Parameters
mapObject map retrieved using getObjectMap().

Definition at line 153 of file Object.cpp.

◆ registerClass()

void registerClass ( const char * name,
const atomic_obj_cpt_t * counters )
staticprotected

Definition at line 227 of file Object.cpp.

◆ set_count()

void set_count ( bool flag)
static

enable/disable class instances counting

Parameters
flagthe counting status to set

Definition at line 71 of file Object.cpp.

◆ toQString()

QString toQString ( const QString & sPrefix = "",
bool bShort = true ) const
virtual

Formatted string version for debugging purposes.

Parameters
sPrefixString prefix which will be added in front of every new line
bShortInstead of the whole content of all classes stored as members just a single unique identifier will be displayed without line breaks.
Returns
String presentation of current object.

Reimplemented in AudioEngine, TransportPosition, ADSR, AutomationPath, Drumkit, DrumkitComponent, Instrument, InstrumentComponent, InstrumentLayer, InstrumentList, Note, Pattern, PatternList, Playlist, Sample, Song, Hydrogen, License, Action, MidiMap, SoundLibraryDatabase, SoundLibraryInfo, and Timeline.

Definition at line 172 of file Object.cpp.

◆ write_objects_map_to()

void write_objects_map_to ( std::ostream & out,
object_map_t * map = nullptr )
static

output the full objects map to a given ostream

Parameters
outthe ostream to write to
mapObject map to print out. Per default the current object map __objects_map will be used.

Definition at line 81 of file Object.cpp.

◆ write_objects_map_to_cerr()

static void write_objects_map_to_cerr ( )
inlinestatic

output objects map to stderr

Definition at line 95 of file Object.h.

Field Documentation

◆ __count

bool __count = false
staticprotected

should we count class instances

Definition at line 153 of file Object.h.

◆ __last_clock

timeval __last_clock = { 0, 0 }
staticprotected

Definition at line 156 of file Object.h.

◆ __logger

Logger * __logger = nullptr
staticprotected

Definition at line 154 of file Object.h.

◆ __mutex

pthread_mutex_t __mutex
staticprivate

yeah this has to be thread safe

Definition at line 161 of file Object.h.

◆ __objects_count

std::atomic< int > __objects_count
staticprivate

total objects count

Definition at line 159 of file Object.h.

◆ __objects_map

object_internal_map_t __objects_map
staticprivate

objects classes and instances count structure

Definition at line 160 of file Object.h.

◆ sPrintIndention

QString sPrintIndention = " "
static

String used to format the debugging string output of some core classes.

Definition at line 127 of file Object.h.