hydrogen 1.2.3
PatternList Class Reference

PatternList is a collection of patterns. More...

#include <PatternList.h>

Inheritance diagram for PatternList:
Object< PatternList > AudioEngineLocking Base

Public Member Functions

 PatternList ()
 constructor
 
 PatternList (PatternList *other)
 copy constructor
 
 ~PatternList ()
 destructor
 
void add (Pattern *pattern, bool bAddVirtuals=false)
 add a pattern to the list
 
std::vector< Pattern * >::iterator begin ()
 Iteration.
 
bool check_name (QString patternName, Pattern *ignore=NULL)
 check if a pattern with name patternName already exists in this list
 
void clear ()
 empty the pattern list
 
Patterndel (int idx)
 remove the pattern at a given index, does not delete it
 
Patterndel (Pattern *pattern)
 remove a pattern from the list, does not delete it
 
std::vector< Pattern * >::iterator end ()
 
Patternfind (const QString &name)
 find a pattern within the patterns
 
QString find_unused_pattern_name (QString sourceName, Pattern *ignore=NULL)
 find unused patternName
 
void flattened_virtual_patterns_compute ()
 call compute_flattened_virtual_patterns on each pattern
 
Patternget (int idx)
 get a pattern from the list
 
Patternget (int idx) const
 
int index (const Pattern *pattern) const
 get the index of the pattern within the patterns
 
void insert (int idx, Pattern *pattern)
 insert a pattern into the list
 
int longest_pattern_length (bool bIncludeVirtuals=true) const
 Get the length of the longest pattern in the list.
 
void move (int idx_a, int idx_b)
 move a pattern from a position to another
 
void operator<< (Pattern *new_pattern)
 add a pattern to the list
 
Patternoperator[] (int idx)
 get a pattern from the list
 
Patternreplace (int idx, Pattern *pattern)
 replace the pattern at a given index with a new one
 
void save_to (XMLNode *pNode, const std::shared_ptr< Instrument > pInstrumentOnly=nullptr) const
 
void set_to_old ()
 mark all patterns as old
 
int size () const
 returns the numbers of patterns
 
void swap (int idx_a, int idx_b)
 swap the patterns of two different indexes
 
QString toQString (const QString &sPrefix="", bool bShort=true) const override
 Formatted string version for debugging purposes.
 
void virtual_pattern_del (Pattern *pattern)
 call del_virtual_pattern on each pattern
 
- Public Member Functions inherited from Object< PatternList >
 Object ()
 
 Object (const Object< PatternList > &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.
 
- Public Member Functions inherited from AudioEngineLocking
 AudioEngineLocking ()
 
void setNeedsLock (bool bNeedsLock)
 The audio processing thread can modify some PatternLists.
 

Static Public Member Functions

static PatternListload_from (XMLNode *pNode, std::shared_ptr< InstrumentList > pInstrumentList, bool bSilent=false)
 load a PatternList from an XMLNode
 
- 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 Attributes

std::vector< Pattern * > __patterns
 the list of patterns
 

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< PatternList >
 ~Object ()
 
- Protected Member Functions inherited from Base
 ~Base ()
 
- Protected Member Functions inherited from AudioEngineLocking
void assertAudioEngineLocked () const
 Assert that the AudioEngine lock is held if needed.
 
- 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

PatternList is a collection of patterns.

Definition at line 42 of file PatternList.h.

Constructor & Destructor Documentation

◆ PatternList() [1/2]

constructor

Definition at line 36 of file PatternList.cpp.

◆ ~PatternList()

destructor

Definition at line 48 of file PatternList.cpp.

◆ PatternList() [2/2]

copy constructor

Parameters
other

Definition at line 40 of file PatternList.cpp.

Member Function Documentation

◆ add()

void add ( Pattern * pattern,
bool bAddVirtuals = false )

add a pattern to the list

Parameters
patterna pointer to the pattern to add
bAddVirtualsWhether virtual patterns contained in pattern should be added too.

Definition at line 97 of file PatternList.cpp.

◆ begin()

std::vector< Pattern * >::iterator begin ( )

Iteration.

Definition at line 373 of file PatternList.cpp.

◆ check_name()

bool check_name ( QString patternName,
Pattern * ignore = NULL )

check if a pattern with name patternName already exists in this list

Parameters
patternNamename of a pattern to check
ignoreoptional pattern in the list to ignore

Definition at line 284 of file PatternList.cpp.

◆ clear()

void clear ( )
inline

empty the pattern list

Definition at line 208 of file PatternList.h.

◆ del() [1/2]

Pattern * del ( int idx)

remove the pattern at a given index, does not delete it

Parameters
idxthe index
Returns
a pointer to the removed pattern

Definition at line 186 of file PatternList.cpp.

◆ del() [2/2]

Pattern * del ( Pattern * pattern)

remove a pattern from the list, does not delete it

Parameters
patternthe pattern to be removed
Returns
a pointer to the removed pattern, 0 if not found

Definition at line 197 of file PatternList.cpp.

◆ end()

std::vector< Pattern * >::iterator end ( )

Definition at line 378 of file PatternList.cpp.

◆ find()

Pattern * find ( const QString & name)

find a pattern within the patterns

Parameters
namethe name of the pattern to find
Returns
0 if not found

Definition at line 237 of file PatternList.cpp.

◆ find_unused_pattern_name()

QString find_unused_pattern_name ( QString sourceName,
Pattern * ignore = NULL )

find unused patternName

Parameters
sourceNamebase name to start with
ignoreoptional pattern in the list to ignore

Definition at line 298 of file PatternList.cpp.

◆ flattened_virtual_patterns_compute()

void flattened_virtual_patterns_compute ( )

call compute_flattened_virtual_patterns on each pattern

Definition at line 269 of file PatternList.cpp.

◆ get() [1/2]

Pattern * get ( int idx)

get a pattern from the list

Parameters
idxthe index to get the pattern from

Definition at line 154 of file PatternList.cpp.

◆ get() [2/2]

Pattern * get ( int idx) const

Definition at line 165 of file PatternList.cpp.

◆ index()

int index ( const Pattern * pattern) const

get the index of the pattern within the patterns

Parameters
patterna pointer to the pattern to find
Returns
-1 if not found

Definition at line 176 of file PatternList.cpp.

◆ insert()

void insert ( int idx,
Pattern * pattern )

insert a pattern into the list

Parameters
idxthe index to insert the pattern at
patterna pointer to the pattern to add

Definition at line 141 of file PatternList.cpp.

◆ load_from()

PatternList * load_from ( XMLNode * pNode,
std::shared_ptr< InstrumentList > pInstrumentList,
bool bSilent = false )
static

load a PatternList from an XMLNode

Parameters
pNodethe XMLDode to read from
pInstrumentListthe current instrument list to search instrument into
bSilentWhether infos, warnings, and errors should be logged.
Returns
a new Pattern instance

Definition at line 56 of file PatternList.cpp.

◆ longest_pattern_length()

int longest_pattern_length ( bool bIncludeVirtuals = true) const

Get the length of the longest pattern in the list.

Parameters
bIncludeVirtualsIn case there are virtual patterns present this argument specifies whether to include their contained patterns as well.
Returns
pattern length in ticks, -1 if list is empty

Definition at line 332 of file PatternList.cpp.

◆ move()

void move ( int idx_a,
int idx_b )

move a pattern from a position to another

Parameters
idx_athe start index
idx_bthe finish index

Definition at line 257 of file PatternList.cpp.

◆ operator<<()

void operator<< ( Pattern * new_pattern)
inline

add a pattern to the list

Parameters
new_patterna pointer to the pattern to add

Definition at line 213 of file PatternList.h.

◆ operator[]()

Pattern * operator[] ( int idx)
inline

get a pattern from the list

Parameters
idxthe index to get the pattern from

Definition at line 218 of file PatternList.h.

◆ replace()

Pattern * replace ( int idx,
Pattern * pattern )

replace the pattern at a given index with a new one

Parameters
idxthe index
patternthe new pattern to insert
Returns
a pointer to the removed pattern, 0 if index out of bounds

Definition at line 208 of file PatternList.cpp.

◆ save_to()

void save_to ( XMLNode * pNode,
const std::shared_ptr< Instrument > pInstrumentOnly = nullptr ) const

Definition at line 87 of file PatternList.cpp.

◆ set_to_old()

void set_to_old ( )

mark all patterns as old

Definition at line 230 of file PatternList.cpp.

◆ size()

int size ( ) const
inline

returns the numbers of patterns

Definition at line 203 of file PatternList.h.

◆ swap()

void swap ( int idx_a,
int idx_b )

swap the patterns of two different indexes

Parameters
idx_athe first index
idx_bthe second index

Definition at line 245 of file PatternList.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 350 of file PatternList.cpp.

◆ virtual_pattern_del()

void virtual_pattern_del ( Pattern * pattern)

call del_virtual_pattern on each pattern

Parameters
patternthe pattern to remove where it's found

Definition at line 279 of file PatternList.cpp.

Field Documentation

◆ __patterns

std::vector<Pattern*> __patterns
private

the list of patterns

Definition at line 197 of file PatternList.h.