CatNiP prefinal
Sähköinen nuottikirja, HY-TKTKL-OHTUPROJ KESÄ11
|
LocalDataHandler.m CatNiP. More...
#import <LocalDataHandler.h>
Public Member Functions | |
(id) | - init [implementation] |
(int) | - int_cmp [implementation] |
Static Public Member Functions | |
(BOOL) | + compositionDataArray:hasScoreWithPdfInScoreArray: |
Searchs if given CompositionData array has score with same pdf filepath as any of the scores in given score array. | |
(NSMutableDictionary *) | + createComposerDictionary: |
Create dictionary from given LocalScoreData array with composers as keys and NSMutableArrays of CompositionData objects as values. | |
(LocalScoreData *) | + createLocalScoreData:ofComposition:localScores: |
Creates LocalScoreData objects for given parameters. | |
(void) | + deleteFile: |
Attemps to delete file in filepath from memory. | |
(void) | + deleteFiles: |
Attemps to delete files in filepaths from memory. | |
(NSMutableArray *) | + loadLocalScoresFromDefaultFile |
Loads and returns previously saved LocalScoreDatas from default file. | |
(NSMutableArray *) | + loadPlaylistsFromDefaultFile: |
Loads and returns previously saved playlist array from default file. | |
(void) | + removeAndDeleteCompositionDataArray:fromScoreArray:andDictionary:andPlaylistArray: |
Removes references and deletes pdf-files associated with scores in given CompositionData array from given score array, dictionary and playlist array. | |
(void) | + removeAndDeleteLocalScoreData:fromScoreArray:andDictionary:andPlaylistArray: |
Removes references and deletes pdf-files associated with given LocalScoreData from given score array, dictionary and playlist array. | |
(void) | + removeAndDeleteScoreDataArray:fromScoreArray:andDictionary:andPlaylistArray: |
Removes references and deletes pdf-files associated with scores in given LocalScoreData array from given score array, dictionary and playlist array. | |
(void) | + removeCompositionDataArray:fromDictionary: |
Removes references to scores in CompositionData array from dictionary. | |
(void) | + removeCompositionDataArray:fromPlaylistArray: |
Removes references to scores in CompositionData array from playlist arrays scorelists. | |
(void) | + removeCompositionDataArray:fromScoreArray: |
Removes references to scores in CompositionData array from score array. | |
(void) | + removeLocalScoreData:fromDictionary: |
Removes reference(s) to given LocalScoreData from dictionary. | |
(void) | + removeLocalScoreData:fromPlaylistArray: |
Remove references of LocalScoreData from given Playlist array. | |
(void) | + removeLocalScoreData:fromScoreArray: |
Removes reference(s) to given LocalScoreData from array of LocalScoreData objects. | |
(void) | + removeScoreDataArray:fromDictionary: |
Removes references to scores in LocalScoreData array from dictionary. | |
(void) | + removeScoreDataArray:fromPlaylistArray: |
Removes references to scores in LocalScoreData array from playlist array's scorelists. | |
(void) | + removeScoreDataArray:fromScoreArray: |
Removes references to scores in LocalScoreData array from score array. | |
(void) | + savePlaylistsToDefaultFile: |
Saves given array of Playlist objects to default file. | |
(void) | + saveScoresToDefaultFile: |
Saves given array of LocalScoreData objects to default file. | |
(BOOL) | + scoreArray:hasScoreWithPdfFileName: |
Searchs if given score array has score with same pdf filename as given parameter. | |
(BOOL) | + scoreArray:hasScoreWithPdfFilePath: |
Searchs if given score array has score with same pdf filepath and name as given parameter. | |
(NSInteger) | + searchFreeIndexForScore: |
Searches given array of LocalScoreDatas for first free index and return it. |
LocalDataHandler.m CatNiP.
Class to handle all local data saving and loading. Also manages local data types by removing references and deleting files.
Created by Simo M Linkola, tkol on 6/10/11. Copyright 2011 __MyCompanyName__. All rights reserved.
Definition at line 19 of file LocalDataHandler.h.
+ (BOOL) compositionDataArray: | (NSArray *) | cdarray | |
hasScoreWithPdfInScoreArray: | (NSArray *) | sarray | |
Searchs if given CompositionData array has score with same pdf filepath as any of the scores in given score array.
compositionDataArray | NSArray of CompositionData objects |
hasScoreWithPdfInScoreArray | NSArray of LocalScoreData objects to search for matching pdfs |
Definition at line 660 of file LocalDataHandler.m.
References CompositionData::musicScores.
+ (NSMutableDictionary *) createComposerDictionary: | (NSArray *) | scores |
Create dictionary from given LocalScoreData array with composers as keys and NSMutableArrays of CompositionData objects as values.
Does not allow duplicate scores to be added.
Duplicates are checked by searching first if composer exists, then if composition exists and then searching compositions scores for same .pdf filepath. If two separate compositions are associated with pdf-files with same filepath WILL ALLOW both to be added.
createComposerDictionary | array of LocalScoreDatas from which the dictionary will be created |
Definition at line 302 of file LocalDataHandler.m.
References LocalScoreData::composer, CompositionData::composerName, LocalScoreData::composition, CompositionData::compositionName, CompositionData::musicScores, and ScoreData::pdf.
+ (LocalScoreData *) createLocalScoreData: | (NSArray *) | fileNameParams | |
ofComposition: | (CompositionData *) | comp | |
localScores: | (NSArray *) | scores | |
Creates LocalScoreData objects for given parameters.
fileNameParams | Array for score's file name (0) and file path (1) |
ofComposition | CompositionData object of given composer and composition created by IMSLP composition query. Contains composer and composition name and array of ScoreData objects. |
localScores | Array of LocalScoreData objects |
Definition at line 217 of file LocalDataHandler.m.
References LocalScoreData::composer, CompositionData::composerName, LocalScoreData::composition, CompositionData::compositionName, ScoreData::description, ScoreData::fullMetaData, LocalScoreData::index, ScoreData::metaDataDict, CompositionData::musicScores, ScoreData::pdf, searchFreeIndexForScore:, and LocalScoreData::userNotes.
+ (void) deleteFile: | (NSString *) | filepath |
Attemps to delete file in filepath from memory.
deleteFile | NSString object representing filepath to the file to be deleted. |
Definition at line 27 of file LocalDataHandler.m.
+ (void) deleteFiles: | (NSArray *) | filepaths |
Attemps to delete files in filepaths from memory.
deleteFiles | NSArray of NSString objects representing filepaths to files to be deleted. |
Definition at line 44 of file LocalDataHandler.m.
- (id) init | [implementation] |
Definition at line 17 of file LocalDataHandler.m.
- (int) int_cmp | (const void *) | a | |
(const void *) | b | ||
[implementation] |
+ (NSMutableArray *) loadLocalScoresFromDefaultFile |
Loads and returns previously saved LocalScoreDatas from default file.
Default file is 'catnip_local.data' in application's documents-folder.
Definition at line 121 of file LocalDataHandler.m.
+ (NSMutableArray *) loadPlaylistsFromDefaultFile: | (NSArray *) | allScores |
Loads and returns previously saved playlist array from default file.
Default file is 'catnip_playlists.data' in application's documents-folder.
Saved playlists have only information about name and LocalScoreData object's index-properties in array. Therefore each time playlists are loaded allLocalScores are hashed in dictionary with indeces as keys and references to LocalScoreData objects as values. Returned playlist array is formed by searching each saved playlists scores from this hashtable.
loadPlaylistsFromDefaultFile | NSArray of all LocalScoreDatas saved in 'catnip_local.data' |
Definition at line 163 of file LocalDataHandler.m.
References Playlist::scorelist.
+ (void) removeAndDeleteCompositionDataArray: | (NSArray *) | cdarray | |
fromScoreArray: | (NSMutableArray *) | sarray | |
andDictionary: | (NSMutableDictionary *) | dict | |
andPlaylistArray: | (NSMutableArray *) | parray | |
Removes references and deletes pdf-files associated with scores in given CompositionData array from given score array, dictionary and playlist array.
removeAndDeleteCompositionDataArray | NSArray of CompositionData objects |
fromScoreArray | NSArray of LocalScoreData objects |
andDictionary | NSDictionary in form made by createComposerDictionary: |
andPlaylistArray | NSArray of Playlist objects |
Definition at line 601 of file LocalDataHandler.m.
References deleteFiles:, removeCompositionDataArray:fromDictionary:, removeScoreDataArray:fromPlaylistArray:, and removeScoreDataArray:fromScoreArray:.
+ (void) removeAndDeleteLocalScoreData: | (LocalScoreData*) | score | |
fromScoreArray: | (NSMutableArray *) | sarray | |
andDictionary: | (NSMutableDictionary *) | dict | |
andPlaylistArray: | (NSMutableArray *) | parray | |
Removes references and deletes pdf-files associated with given LocalScoreData from given score array, dictionary and playlist array.
removeAndDeleteLocalScoreData | LocalScoreData object to be deleted |
fromScoreArray | NSArray of LocalScoreData objects |
andDictionary | NSDictionary in form made by createComposerDictionary: |
andPlaylistArray | NSArray of Playlist objects |
Definition at line 466 of file LocalDataHandler.m.
References deleteFile:, removeLocalScoreData:fromDictionary:, removeLocalScoreData:fromPlaylistArray:, and removeLocalScoreData:fromScoreArray:.
+ (void) removeAndDeleteScoreDataArray: | (NSArray *) | sdarray | |
fromScoreArray: | (NSMutableArray *) | sarray | |
andDictionary: | (NSMutableDictionary *) | dict | |
andPlaylistArray: | (NSMutableArray *) | parray | |
Removes references and deletes pdf-files associated with scores in given LocalScoreData array from given score array, dictionary and playlist array.
removeAndDeleteScoreDataArray | NSArray of LocalScoreData objects |
fromScoreArray | NSArray of LocalScoreData objects |
andDictionary | NSDictionary in form made by createComposerDictionary: |
andPlaylistArray | NSArray of Playlist objects |
Definition at line 540 of file LocalDataHandler.m.
References removeAndDeleteLocalScoreData:fromScoreArray:andDictionary:andPlaylistArray:.
+ (void) removeCompositionDataArray: | (NSArray *) | cdarray | |
fromDictionary: | (NSMutableDictionary *) | dict | |
Removes references to scores in CompositionData array from dictionary.
removeCompositionDataArray | NSArray of CompositionData objects |
fromDictionary | NSDictionary in form made by createComposerDictionary: |
Definition at line 568 of file LocalDataHandler.m.
References CompositionData::musicScores, and removeScoreDataArray:fromDictionary:.
+ (void) removeCompositionDataArray: | (NSArray *) | cdarray | |
fromPlaylistArray: | (NSMutableArray *) | parray | |
Removes references to scores in CompositionData array from playlist arrays scorelists.
removeCompositionDataArray | NSArray of CompositionData objects |
fromPlaylistArray | NSArray of Playlist objects |
Definition at line 583 of file LocalDataHandler.m.
References CompositionData::musicScores, and removeScoreDataArray:fromPlaylistArray:.
+ (void) removeCompositionDataArray: | (NSArray *) | cdarray | |
fromScoreArray: | (NSMutableArray *) | sarray | |
Removes references to scores in CompositionData array from score array.
removeCompositionDataArray | NSArray of CompositionData objects |
fromScoreArray | NSArray of LocalScoreData objects |
Definition at line 553 of file LocalDataHandler.m.
References CompositionData::musicScores, and removeScoreDataArray:fromScoreArray:.
+ (void) removeLocalScoreData: | (LocalScoreData *) | score | |
fromDictionary: | (NSMutableDictionary *) | dict | |
Removes reference(s) to given LocalScoreData from dictionary.
Does not delete the pdf-file associated with the LocalScoreData object.
References are removed by finding value from dictionary for LocalScoreData's composer as key. NSMutableArray of CompositionData's achieved this way is then searched for object with compositionName same as LocalScoreData's composition. If this is found CompositionData's musicScore-array is searched for a LocalScoreData object with same pdf-attribute value by comparing strings.
removeLocalScoreData | score which references are to be removed |
fromDictionary | dictionary from which the references will be removed. Dictionary needs to be of same format as createComposerDictionary makes. |
Definition at line 402 of file LocalDataHandler.m.
References CompositionData::composerName, LocalScoreData::composition, CompositionData::compositionName, CompositionData::musicScores, and ScoreData::pdf.
+ (void) removeLocalScoreData: | (LocalScoreData *) | score | |
fromPlaylistArray: | (NSMutableArray *) | parray | |
Remove references of LocalScoreData from given Playlist array.
Does not delete the pdf-file associated with the LocalScoreData object.
Uses removeLocalScoreData:fromScoreArray: for each Playlist's scorelist.
removeLocalScoreData | score which references are to be removed |
fromPlaylistArray | array of Playlist objects from which the references will be removed |
Definition at line 450 of file LocalDataHandler.m.
References removeLocalScoreData:fromScoreArray:.
+ (void) removeLocalScoreData: | (LocalScoreData *) | score | |
fromScoreArray: | (NSMutableArray *) | sarray | |
Removes reference(s) to given LocalScoreData from array of LocalScoreData objects.
Does not delete the pdf-file associated with the LocalScoreData object.
References are removed by comparing pdf-attribute of given LocalScoreData to array's LocalScoreData objects' pdf-attribute. If they are the same the object in array is removed from the array.
removeLocalScoreData | score which references are to be removed |
fromScoreArray | array of LocalScoreData objects from which the references will be removed |
Definition at line 371 of file LocalDataHandler.m.
References ScoreData::pdf.
+ (void) removeScoreDataArray: | (NSArray *) | sdarray | |
fromDictionary: | (NSMutableDictionary *) | dict | |
Removes references to scores in LocalScoreData array from dictionary.
removeScoreDataArray | NSArray of LocalScoreData objects |
fromDictionary | NSDictionary in form made by createComposerDictionary: |
Definition at line 495 of file LocalDataHandler.m.
References removeLocalScoreData:fromDictionary:.
+ (void) removeScoreDataArray: | (NSArray *) | sdarray | |
fromPlaylistArray: | (NSMutableArray *) | parray | |
Removes references to scores in LocalScoreData array from playlist array's scorelists.
removeScoreDataArray | NSArray of LocalScoreData objects |
fromPlaylistArray | NSArray of Playlist objects |
Definition at line 509 of file LocalDataHandler.m.
+ (void) removeScoreDataArray: | (NSArray *) | sdarray | |
fromScoreArray: | (NSMutableArray *) | sarray | |
Removes references to scores in LocalScoreData array from score array.
removeScoreDataArray | NSArray of LocalScoreData objects |
fromScoreArray | NSArray of LocalScoreData objects |
Definition at line 481 of file LocalDataHandler.m.
References removeLocalScoreData:fromScoreArray:.
+ (void) savePlaylistsToDefaultFile: | (NSMutableArray *) | playlists |
Saves given array of Playlist objects to default file.
Caller should check that given array has nothing but Playlist objects.
Default file is 'catnip_playlists.data' in application's documents-folder.
Definition at line 89 of file LocalDataHandler.m.
References Playlist::scorelist.
+ (void) saveScoresToDefaultFile: | (NSMutableArray *) | scores |
Saves given array of LocalScoreData objects to default file.
Caller should check that given array has nothing but LocalScoreData objects.
Default file is 'catnip_local.data' in application's documents-folder.
Definition at line 64 of file LocalDataHandler.m.
+ (BOOL) scoreArray: | (NSArray *) | sarray | |
hasScoreWithPdfFileName: | (NSString *) | filename | |
Searchs if given score array has score with same pdf filename as given parameter.
scoreArray | NSArray of LocalScoreData objects |
hasScoreWithPdfFileName | pdf-filename to search from scoreArray |
Definition at line 627 of file LocalDataHandler.m.
+ (BOOL) scoreArray: | (NSArray *) | sarray | |
hasScoreWithPdfFilePath: | (NSString *) | filepath | |
Searchs if given score array has score with same pdf filepath and name as given parameter.
scoreArray | NSArray of LocalScoreData objects |
hasScoreWithPdfFileName | filepath to pdf to search from scoreArray |
Definition at line 643 of file LocalDataHandler.m.
+ (NSInteger) searchFreeIndexForScore: | (NSArray *) | scores |
Searches given array of LocalScoreDatas for first free index and return it.
Indeces start from 1 and increment by one.
searchFreeIndexForScores | NSArray of LocalScoreData objects |
Definition at line 265 of file LocalDataHandler.m.
References int_cmp.