CatNiP docutest
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 | |
(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. | |
(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.
+ (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 |
+ (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 |
+ (void) deleteFile: | (NSString *) | filepath |
Attemps to delete file in filepath from memory.
deleteFile | NSString object representing filepath to the file to be deleted. |
+ (void) deleteFiles: | (NSArray *) | filepaths |
Attemps to delete files in filepaths from memory.
deleteFiles | NSArray of NSString objects representing filepaths to files to be deleted. |
- (id) init | [implementation] |
- (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.
+ (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' |
+ (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 |
+ (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 |
+ (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 |
+ (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: |
+ (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 |
+ (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 |
+ (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. |
+ (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 |
+ (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 |
+ (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: |
+ (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 |
+ (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 |
+ (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.
+ (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.
+ (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 |
+ (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 |