diff --git a/cwPianoScore.cpp b/cwPianoScore.cpp index a058f60..9fe323b 100644 --- a/cwPianoScore.cpp +++ b/cwPianoScore.cpp @@ -14,6 +14,7 @@ namespace cw { event_t* base; event_t* end; + unsigned maxLocId; } score_t; score_t* _handleToPtr(handle_t h) @@ -103,6 +104,10 @@ namespace cw p->base = e; p->end = e; + + // track the max 'loc' id + if( e->loc > p->maxLocId ) + p->maxLocId = e->loc; } @@ -196,8 +201,7 @@ unsigned cw::score::event_count( handle_t h ) for(event_t* e=p->base; e!=nullptr; e=e->link) ++n; - return n; - + return n; } const cw::score::event_t* cw::score::base_event( handle_t h ) @@ -232,3 +236,15 @@ cw::rc_t cw::score::event_to_string( handle_t h, unsigned uid, char* buf, unsig return rc; } + +unsigned cw::score::loc_count( handle_t h ) +{ + score_t* p = _handleToPtr(h); + return p->maxLocId; +} + +bool cw::score::is_loc_valid( handle_t h, unsigned locId ) +{ + score_t* p = _handleToPtr(h); + return locId < p->maxLocId; +} diff --git a/cwPianoScore.h b/cwPianoScore.h index cc9d80e..1dbffb2 100644 --- a/cwPianoScore.h +++ b/cwPianoScore.h @@ -33,9 +33,14 @@ namespace cw rc_t create( handle_t& hRef, const object_t* cfg ); rc_t destroy( handle_t& hRef ); + unsigned event_count( handle_t h ); const event_t* base_event( handle_t h ); - + + unsigned loc_count( handle_t h ); + bool is_loc_valid( handle_t h, unsigned locId ); + + // Format the event as a string for printing. rc_t event_to_string( handle_t h, unsigned uid, char* buf, unsigned buf_byte_cnt );