|
hydrogen 1.2.6
|
#include <Drumkit.h>
Public Member Functions | |
| Drumkit () | |
| drumkit constructor, does nothing | |
| Drumkit (std::shared_ptr< Drumkit > other) | |
| copy constructor | |
| ~Drumkit () | |
| drumkit destructor, delete __instruments | |
| void | addComponent (std::shared_ptr< DrumkitComponent > pComponent) |
| void | addInstrument (std::shared_ptr< Instrument > pInstrument) |
Adds an instrument and takes care of registering DrumkitComponents missing for contained InstrumentComponents (based on their ID). | |
| bool | exportTo (const QString &sTargetDir, const QString &sComponentName="", bool bRecentVersion=true, bool *pUtf8Encoded=nullptr, bool bSilent=false) |
| Compresses the drumkit into a .h2drumkit file. | |
| int | findUnusedComponentId () const |
| 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 License & | get_image_license () const |
| __imageLicense accessor | |
| const QString & | get_info () const |
| __info accessor | |
| std::shared_ptr< InstrumentList > | get_instruments () const |
| returns __instruments | |
| const License & | get_license () const |
| __license accessor | |
| const QString & | get_name () const |
| __name accessor | |
| const QString & | get_path () const |
| __path accessor | |
| std::shared_ptr< DrumkitComponent > | getComponent (int nID) const |
| 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 | logBacktrace () const |
| Print the current stack at point into the debug log. | |
| 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="", QString *pInstalledPath=nullptr, bool *pEncodingIssuesDetected=nullptr, bool bSilent=false) |
| Extract a .h2drumkit file. | |
| static std::shared_ptr< Drumkit > | load (const QString &dk_dir, bool bUpgrade=true, bool *pLegacyFormatEncountered=nullptr, 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 Logger * | logger () |
| 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< Drumkit > | load_from (XMLNode *node, const QString &dk_path, bool *pLegacyFormatEncountered=nullptr, 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 |
| static bool | bLogColors = true |
| Drumkit | ( | ) |
drumkit constructor, does nothing
Definition at line 57 of file Drumkit.cpp.
copy constructor
Definition at line 71 of file Drumkit.cpp.
| ~Drumkit | ( | ) |
drumkit destructor, delete __instruments
Definition at line 90 of file Drumkit.cpp.
| void addComponent | ( | std::shared_ptr< DrumkitComponent > | pComponent | ) |
Definition at line 567 of file Drumkit.cpp.
| void addInstrument | ( | std::shared_ptr< Instrument > | pInstrument | ) |
Adds an instrument and takes care of registering DrumkitComponents missing for contained InstrumentComponents (based on their ID).
Definition at line 589 of file Drumkit.cpp.
| bool exportTo | ( | const QString & | sTargetDir, |
| const QString & | sComponentName = "", | ||
| bool | bRecentVersion = true, | ||
| bool * | pUtf8Encoded = nullptr, | ||
| 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.
| sTargetDir | Folder which will contain the resulting .h2drumkit file. |
| sComponentName | Name of a particular component used in case just a single component should be exported. |
| bRecentVersion | Whether the drumkit format should be supported by Hydrogen 0.9.7 or higher (whether it should be composed of DrumkitComponents). |
| pUtf8Encoded | will be set to true in case we were able to enforce 'UTF-8' as system locale in libarchive. If this didn't work, export will be done using classic Latin1 encoded filenames. |
| bSilent | Whether debug and info messages should be logged. |
Definition at line 964 of file Drumkit.cpp.
| int findUnusedComponentId | ( | ) | const |
Definition at line 547 of file Drumkit.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
__imageLicense accessor
|
inline |
returns __instruments
|
inline |
| std::shared_ptr< DrumkitComponent > getComponent | ( | int | nID | ) | const |
Definition at line 536 of file Drumkit.cpp.
| QString getExportName | ( | const QString & | sComponentName, |
| bool | bRecentVersion ) const |
Returns the base name used when exporting the drumkit.
| sComponentName | Name of a particular component used in case just a single component should be exported. |
| bRecentVersion | Whether the drumkit format should be supported by Hydrogen 0.9.7 or higher (whether it should be composed of DrumkitComponents). |
Definition at line 330 of file Drumkit.cpp.
| 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 326 of file Drumkit.cpp.
|
static |
Extract a .h2drumkit file.
| sSourcePath | Absolute path to the new drumkit archive |
| sTargetPath | Absolute path to where the new drumkit should be extracted to. If left empty, the user's drumkit folder will be used. |
| pInstalledPath | Will contain the actual name of the folder the kit was installed to. In most cases this will coincide with a folder within sTargetPath named like the kit itself. But in case the system does not support UTF-8 encoding and sTargetPath contains characters other than those whitelisted in Filesystem::removeUtf8Characters, those might be omitted and the directory and files created using libarchive might differ. |
| pEncodingIssuesDetected | will be set to true in case at least one filepath of extracted kit had to be altered in order to not run into UTF-8 issues. |
| bSilent | Whether debug and info messages should be logged. |
Definition at line 721 of file Drumkit.cpp.
|
static |
Load drumkit information from a directory.
| dk_dir | A directory containing a drumkit, like those returned by Filesystem::drumkit_dir_search(). |
| bUpgrade | Whether the loaded drumkit should be upgraded using upgrade_drumkit() in case it did not comply with the current XSD file. |
| pLegacyFormatEncountered | will be set to true is any of the XML elements requires legacy format support and left untouched otherwise. |
| bSilent | if set to true, all log messages except of errors and warnings are suppressed. |
Definition at line 94 of file Drumkit.cpp.
|
staticprivate |
load a drumkit from an XMLNode
| node | the XMLDode to read from |
| dk_path | the directory holding the drumkit data |
| pLegacyFormatEncountered | will be set to true is any of the XML elements requires legacy format support and left untouched otherwise. |
| bSilent | if set to true, all log messages except of errors and warnings are suppressed. |
Definition at line 153 of file Drumkit.cpp.
| void load_samples | ( | ) |
Calls the InstrumentList::load_samples() member function of __instruments.
Definition at line 234 of file Drumkit.cpp.
|
staticprivate |
Loads the drumkit stored in sDrumkitDir into pDoc and takes care of all the error handling.
Definition at line 265 of file Drumkit.cpp.
|
static |
Loads the license information of a drumkit contained in directory sDrumkitDir.
| sDrumkitDir | Directory containing a drumkit.xml file. |
Definition at line 243 of file Drumkit.cpp.
| void propagateLicense | ( | ) |
Assign the license stored in #m_license to all samples contained in the kit.
Definition at line 677 of file Drumkit.cpp.
|
static |
remove a drumkit from the disk
| sDrumkitDir | Path to Drumkit |
Definition at line 704 of file Drumkit.cpp.
|
inline |
| 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.
| sDrumkitPath | the path (folder) to save the Drumkit into. If left empty, the path stored in __path will be used instead. |
| nComponentID | to chose the component to save or -1 for all |
| bSilent | if set to true, all log messages except of errors and warnings are suppressed. |
Definition at line 343 of file Drumkit.cpp.
|
private |
save the drumkit image into the new directory
| dk_dir | the directory to save the image into |
| bSilent | Whether to suppress info and warning log level messages. |
Definition at line 521 of file Drumkit.cpp.
|
private |
save a drumkit instruments samples into a directory
| dk_dir | the directory to save the samples into |
| bSilent | Whether to suppress info and warning log level messages. |
Definition at line 478 of file Drumkit.cpp.
|
private |
Definition at line 415 of file Drumkit.cpp.
|
inline |
| void set_components | ( | std::shared_ptr< std::vector< std::shared_ptr< DrumkitComponent > > > | components | ) |
Definition at line 672 of file Drumkit.cpp.
|
inline |
|
inline |
__imageLicense setter
|
inline |
| void set_instruments | ( | std::shared_ptr< InstrumentList > | instruments | ) |
set __instruments, delete existing one
Definition at line 667 of file Drumkit.cpp.
|
inline |
|
inline |
|
inline |
| 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 700 of file Drumkit.cpp.
|
overridevirtual |
Formatted string version for debugging purposes.
| sPrefix | String prefix which will be added in front of every new line |
| bShort | Instead of the whole content of all classes stored as members just a single unique identifier will be displayed without line breaks. |
Reimplemented from Base.
Definition at line 1391 of file Drumkit.cpp.
| void unload_samples | ( | ) |
Calls the InstrumentList::unload_samples() member function of __instruments.
Definition at line 317 of file Drumkit.cpp.
|
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 290 of file Drumkit.cpp.
|
private |
|
private |