hydrogen 1.2.3
Drumkit Class Reference

Drumkit info. More...

#include <Drumkit.h>

Inheritance diagram for Drumkit:
Object< Drumkit > Base

Public Member Functions

 Drumkit ()
 drumkit constructor, does nothing
 
 Drumkit (std::shared_ptr< Drumkit > other)
 copy constructor
 
 ~Drumkit ()
 drumkit destructor, delete __instruments
 
bool exportTo (const QString &sTargetDir, const QString &sComponentName="", bool bRecentVersion=true, bool bSilent=false)
 Compresses the drumkit into a .h2drumkit file.
 
const QString & get_author () const
 __author accessor
 
std::shared_ptr< std::vector< std::shared_ptr< DrumkitComponent > > > get_components ()
 
const QString & get_image () const
 __image accessor
 
const Licenseget_image_license () const
 __imageLicense accessor
 
const QString & get_info () const
 __info accessor
 
std::shared_ptr< InstrumentListget_instruments () const
 returns __instruments
 
const Licenseget_license () const
 __license accessor
 
const QString & get_name () const
 __name accessor
 
const QString & get_path () const
 __path accessor
 
QString getExportName (const QString &sComponentName, bool bRecentVersion) const
 Returns the base name used when exporting the drumkit.
 
QString getFolderName () const
 Returns a version of __name stripped of all whitespaces and other characters which would prevent its use as a valid filename.
 
void load_samples ()
 Calls the InstrumentList::load_samples() member function of __instruments.
 
void propagateLicense ()
 Assign the license stored in #m_license to all samples contained in the kit.
 
const bool samples_loaded () const
 return true if the samples are loaded
 
bool save (const QString &sDrumkitPath="", int nComponentID=-1, bool bRecentVersion=true, bool bSilent=false)
 Save a drumkit to disk.
 
void set_author (const QString &author)
 __author setter
 
void set_components (std::shared_ptr< std::vector< std::shared_ptr< DrumkitComponent > > > components)
 
void set_image (const QString &image)
 __image setter
 
void set_image_license (const License &imageLicense)
 __imageLicense setter
 
void set_info (const QString &info)
 __info setter
 
void set_instruments (std::shared_ptr< InstrumentList > instruments)
 set __instruments, delete existing one
 
void set_license (const License &license)
 __license setter
 
void set_name (const QString &name)
 __name setter
 
void set_path (const QString &path)
 __path setter
 
std::vector< std::shared_ptr< InstrumentList::Content > > summarizeContent () const
 Returns vector of lists containing instrument name, component name, file name, the license of all associated samples.
 
QString toQString (const QString &sPrefix="", bool bShort=true) const override
 Formatted string version for debugging purposes.
 
void unload_samples ()
 Calls the InstrumentList::unload_samples() member function of __instruments.
 
- Public Member Functions inherited from Object< Drumkit >
 Object ()
 
 Object (const Object< Drumkit > &other)
 
- Public Member Functions inherited from Base
 Base ()
 
 Base (const Base &other)
 
virtual const char * class_name () const
 
void Print (bool bShort=true) const
 Prints content of toQString() via DEBUGLOG.
 

Static Public Member Functions

static bool install (const QString &sSourcePath, const QString &sTargetPath="", bool bSilent=false)
 Extract a .h2drumkit file.
 
static std::shared_ptr< Drumkitload (const QString &dk_dir, bool bUpgrade=true, bool bSilent=false)
 Load drumkit information from a directory.
 
static License loadLicenseFrom (const QString &sDrumkitDir, bool bSilent=false)
 Loads the license information of a drumkit contained in directory sDrumkitDir.
 
static bool remove (const QString &sDrumkitDir)
 remove a drumkit from the disk
 
static void upgrade_drumkit (std::shared_ptr< Drumkit > pDrumkit, const QString &dk_path, bool bSilent=false)
 Saves the current drumkit to dk_path, but makes a backup.
 
- Static Public Member Functions inherited from Base
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
 

Private Member Functions

bool save_image (const QString &dk_dir, bool bSilent=false) const
 save the drumkit image into the new directory
 
bool save_samples (const QString &dk_dir, bool bSilent=false) const
 save a drumkit instruments samples into a directory
 
void save_to (XMLNode *node, int component_id=-1, bool bRecentVersion=true, bool bSilent=false) const
 

Static Private Member Functions

static std::shared_ptr< Drumkitload_from (XMLNode *node, const QString &dk_path, bool bSilent=false)
 load a drumkit from an XMLNode
 
static bool loadDoc (const QString &sDrumkitDir, XMLDoc *pDoc, bool bSilent=false)
 Loads the drumkit stored in sDrumkitDir into pDoc and takes care of all the error handling.
 

Private Attributes

QString __author
 drumkit author
 
std::shared_ptr< std::vector< std::shared_ptr< DrumkitComponent > > > __components
 list of drumkit component
 
QString __image
 drumkit image filename
 
License __imageLicense
 drumkit image license
 
QString __info
 drumkit free text
 
std::shared_ptr< InstrumentList__instruments
 the list of instruments
 
License __license
 drumkit license description
 
QString __name
 drumkit name
 
QString __path
 absolute drumkit path
 
bool __samples_loaded
 true if the instrument samples are loaded
 

Additional Inherited Members

- Static Public Attributes inherited from Base
static QString sPrintIndention = " "
 String used to format the debugging string output of some core classes.
 
- Protected Member Functions inherited from Object< Drumkit >
 ~Object ()
 
- Protected Member Functions inherited from Base
 ~Base ()
 
- Static Protected Member Functions inherited from Base
static void registerClass (const char *name, const atomic_obj_cpt_t *counters)
 
- Static Protected Attributes inherited from Base
static bool __count = false
 should we count class instances
 
static timeval __last_clock = { 0, 0 }
 
static Logger__logger = nullptr
 

Detailed Description

Drumkit info.

Definition at line 44 of file Drumkit.h.

Constructor & Destructor Documentation

◆ Drumkit() [1/2]

Drumkit ( )

drumkit constructor, does nothing

Definition at line 53 of file Drumkit.cpp.

◆ Drumkit() [2/2]

Drumkit ( std::shared_ptr< Drumkit > other)

copy constructor

Definition at line 67 of file Drumkit.cpp.

◆ ~Drumkit()

~Drumkit ( )

drumkit destructor, delete __instruments

Definition at line 86 of file Drumkit.cpp.

Member Function Documentation

◆ exportTo()

bool exportTo ( const QString & sTargetDir,
const QString & sComponentName = "",
bool bRecentVersion = true,
bool bSilent = false )

Compresses the drumkit into a .h2drumkit file.

The name of the created file will be a concatenation of __name and Filesystem::drumkit_ext.

exportTo() ? well, export is a protected name within C++. So, we needed a less obvious name.

Parameters
sTargetDirFolder which will contain the resulting .h2drumkit file.
sComponentNameName of a particular component used in case just a single component should be exported.
bRecentVersionWhether the drumkit format should be supported by Hydrogen 0.9.7 or higher (whether it should be composed of DrumkitComponents).
bSilentWhether debug and info messages should be logged.
Returns
true on success

Definition at line 718 of file Drumkit.cpp.

◆ get_author()

const QString & get_author ( ) const
inline

__author accessor

Definition at line 336 of file Drumkit.h.

◆ get_components()

std::shared_ptr< std::vector< std::shared_ptr< DrumkitComponent > > > get_components ( )
inline

Definition at line 386 of file Drumkit.h.

◆ get_image()

const QString & get_image ( ) const
inline

__image accessor

Definition at line 366 of file Drumkit.h.

◆ get_image_license()

const License & get_image_license ( ) const
inline

__imageLicense accessor

Definition at line 376 of file Drumkit.h.

◆ get_info()

const QString & get_info ( ) const
inline

__info accessor

Definition at line 346 of file Drumkit.h.

◆ get_instruments()

std::shared_ptr< InstrumentList > get_instruments ( ) const
inline

returns __instruments

Definition at line 304 of file Drumkit.h.

◆ get_license()

const License & get_license ( ) const
inline

__license accessor

Definition at line 356 of file Drumkit.h.

◆ get_name()

const QString & get_name ( ) const
inline

__name accessor

Definition at line 324 of file Drumkit.h.

◆ get_path()

const QString & get_path ( ) const
inline

__path accessor

Definition at line 314 of file Drumkit.h.

◆ getExportName()

QString getExportName ( const QString & sComponentName,
bool bRecentVersion ) const

Returns the base name used when exporting the drumkit.

Parameters
sComponentNameName of a particular component used in case just a single component should be exported.
bRecentVersionWhether the drumkit format should be supported by Hydrogen 0.9.7 or higher (whether it should be composed of DrumkitComponents).

Definition at line 307 of file Drumkit.cpp.

◆ getFolderName()

QString getFolderName ( ) const

Returns a version of __name stripped of all whitespaces and other characters which would prevent its use as a valid filename.

Attention: The returned string might be used as the name for the associated drumkit folder but it does not have to.

Definition at line 303 of file Drumkit.cpp.

◆ install()

bool install ( const QString & sSourcePath,
const QString & sTargetPath = "",
bool bSilent = false )
static

Extract a .h2drumkit file.

Parameters
sSourcePathAbsolute path to the new drumkit archive
sTargetPathAbsolute path to where the new drumkit should be extracted to. If left empty, the user's drumkit folder will be used.
bSilentWhether debug and info messages should be logged.
Returns
true on success

Definition at line 565 of file Drumkit.cpp.

◆ load()

std::shared_ptr< Drumkit > load ( const QString & dk_dir,
bool bUpgrade = true,
bool bSilent = false )
static

Load drumkit information from a directory.

Parameters
dk_dirA directory containing a drumkit, like those returned by Filesystem::drumkit_dir_search().
bUpgradeWhether the loaded drumkit should be upgraded using upgrade_drumkit() in case it did not comply with the current XSD file.
bSilentif set to true, all log messages except of errors and warnings are suppressed.
Returns
A Drumkit on success, nullptr otherwise.

Definition at line 90 of file Drumkit.cpp.

◆ load_from()

std::shared_ptr< Drumkit > load_from ( XMLNode * node,
const QString & dk_path,
bool bSilent = false )
staticprivate

load a drumkit from an XMLNode

Parameters
nodethe XMLDode to read from
dk_paththe directory holding the drumkit data
bSilentif set to true, all log messages except of errors and warnings are suppressed.

Definition at line 134 of file Drumkit.cpp.

◆ load_samples()

void load_samples ( )

Calls the InstrumentList::load_samples() member function of __instruments.

Definition at line 204 of file Drumkit.cpp.

◆ loadDoc()

bool loadDoc ( const QString & sDrumkitDir,
XMLDoc * pDoc,
bool bSilent = false )
staticprivate

Loads the drumkit stored in sDrumkitDir into pDoc and takes care of all the error handling.

Returns
true on success.

Definition at line 235 of file Drumkit.cpp.

◆ loadLicenseFrom()

License loadLicenseFrom ( const QString & sDrumkitDir,
bool bSilent = false )
static

Loads the license information of a drumkit contained in directory sDrumkitDir.

Parameters
sDrumkitDirDirectory containing a drumkit.xml file.

Definition at line 213 of file Drumkit.cpp.

◆ propagateLicense()

void propagateLicense ( )

Assign the license stored in #m_license to all samples contained in the kit.

Definition at line 521 of file Drumkit.cpp.

◆ remove()

bool remove ( const QString & sDrumkitDir)
static

remove a drumkit from the disk

Parameters
sDrumkitDirPath to Drumkit
Returns
true on success

Definition at line 548 of file Drumkit.cpp.

◆ samples_loaded()

const bool samples_loaded ( ) const
inline

return true if the samples are loaded

Definition at line 381 of file Drumkit.h.

◆ save()

bool save ( const QString & sDrumkitPath = "",
int nComponentID = -1,
bool bRecentVersion = true,
bool bSilent = false )

Save a drumkit to disk.

It takes care of writing all parameters etc. into a drumkit.xml file as well as copying both associated samples and images.

Parameters
sDrumkitPaththe path (folder) to save the Drumkit into. If left empty, the path stored in __path will be used instead.
nComponentIDto chose the component to save or -1 for all
bSilentif set to true, all log messages except of errors and warnings are suppressed.
Returns
true on success

Definition at line 320 of file Drumkit.cpp.

◆ save_image()

bool save_image ( const QString & dk_dir,
bool bSilent = false ) const
private

save the drumkit image into the new directory

Parameters
dk_dirthe directory to save the image into
bSilentWhether to suppress info and warning log level messages.
Returns
true on success

Definition at line 496 of file Drumkit.cpp.

◆ save_samples()

bool save_samples ( const QString & dk_dir,
bool bSilent = false ) const
private

save a drumkit instruments samples into a directory

Parameters
dk_dirthe directory to save the samples into
bSilentWhether to suppress info and warning log level messages.
Returns
true on success

Definition at line 455 of file Drumkit.cpp.

◆ save_to()

void save_to ( XMLNode * node,
int component_id = -1,
bool bRecentVersion = true,
bool bSilent = false ) const
private

Definition at line 392 of file Drumkit.cpp.

◆ set_author()

void set_author ( const QString & author)
inline

__author setter

Definition at line 329 of file Drumkit.h.

◆ set_components()

void set_components ( std::shared_ptr< std::vector< std::shared_ptr< DrumkitComponent > > > components)

Definition at line 516 of file Drumkit.cpp.

◆ set_image()

void set_image ( const QString & image)
inline

__image setter

Definition at line 361 of file Drumkit.h.

◆ set_image_license()

void set_image_license ( const License & imageLicense)
inline

__imageLicense setter

Definition at line 371 of file Drumkit.h.

◆ set_info()

void set_info ( const QString & info)
inline

__info setter

Definition at line 341 of file Drumkit.h.

◆ set_instruments()

void set_instruments ( std::shared_ptr< InstrumentList > instruments)

set __instruments, delete existing one

Definition at line 511 of file Drumkit.cpp.

◆ set_license()

void set_license ( const License & license)
inline

__license setter

Definition at line 351 of file Drumkit.h.

◆ set_name()

void set_name ( const QString & name)
inline

__name setter

Definition at line 319 of file Drumkit.h.

◆ set_path()

void set_path ( const QString & path)
inline

__path setter

Definition at line 309 of file Drumkit.h.

◆ summarizeContent()

std::vector< std::shared_ptr< InstrumentList::Content > > summarizeContent ( ) const

Returns vector of lists containing instrument name, component name, file name, the license of all associated samples.

Definition at line 544 of file Drumkit.cpp.

◆ toQString()

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

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 from Base.

Definition at line 1042 of file Drumkit.cpp.

◆ unload_samples()

void unload_samples ( )

Calls the InstrumentList::unload_samples() member function of __instruments.

Definition at line 294 of file Drumkit.cpp.

◆ upgrade_drumkit()

void upgrade_drumkit ( std::shared_ptr< Drumkit > pDrumkit,
const QString & dk_path,
bool bSilent = false )
static

Saves the current drumkit to dk_path, but makes a backup.

This is used when the drumkit did not comply to our xml schema.

Definition at line 267 of file Drumkit.cpp.

Field Documentation

◆ __author

QString __author
private

drumkit author

Definition at line 246 of file Drumkit.h.

◆ __components

std::shared_ptr<std::vector<std::shared_ptr<DrumkitComponent> > > __components
private

list of drumkit component

Definition at line 254 of file Drumkit.h.

◆ __image

QString __image
private

drumkit image filename

Definition at line 249 of file Drumkit.h.

◆ __imageLicense

License __imageLicense
private

drumkit image license

Definition at line 250 of file Drumkit.h.

◆ __info

QString __info
private

drumkit free text

Definition at line 247 of file Drumkit.h.

◆ __instruments

std::shared_ptr<InstrumentList> __instruments
private

the list of instruments

Definition at line 253 of file Drumkit.h.

◆ __license

License __license
private

drumkit license description

Definition at line 248 of file Drumkit.h.

◆ __name

QString __name
private

drumkit name

Definition at line 245 of file Drumkit.h.

◆ __path

QString __path
private

absolute drumkit path

Definition at line 244 of file Drumkit.h.

◆ __samples_loaded

bool __samples_loaded
private

true if the instrument samples are loaded

Definition at line 252 of file Drumkit.h.