CatNiP prefinal
Sähköinen nuottikirja, HY-TKTKL-OHTUPROJ KESÄ11
LocalDataHandler Class Reference

LocalDataHandler.m CatNiP. More...

#import <LocalDataHandler.h>

List of all members.

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.

Detailed Description

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.


Member Function Documentation

+ (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.

Parameters:
compositionDataArrayNSArray of CompositionData objects
hasScoreWithPdfInScoreArrayNSArray of LocalScoreData objects to search for matching pdfs
Returns:
YES is match is found. NO otherwise.

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.

Parameters:
createComposerDictionaryarray of LocalScoreDatas from which the dictionary will be created
Returns:
created dictionary with composers as keys and NSMutableArrays of CompositionDatas as values.

Definition at line 302 of file LocalDataHandler.m.

References LocalScoreData::composer, CompositionData::composerName, LocalScoreData::composition, CompositionData::compositionName, CompositionData::musicScores, and ScoreData::pdf.

Here is the caller graph for this function:

+ (LocalScoreData *) createLocalScoreData: (NSArray *)  fileNameParams
ofComposition: (CompositionData *)  comp
localScores: (NSArray *)  scores 

Creates LocalScoreData objects for given parameters.

Parameters:
fileNameParamsArray for score's file name (0) and file path (1)
ofCompositionCompositionData object of given composer and composition created by IMSLP composition query. Contains composer and composition name and array of ScoreData objects.
localScoresArray of LocalScoreData objects
Returns:
LocalScoreData object representing given arguments

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.

Here is the call graph for this function:

Here is the caller graph for this function:

+ (void) deleteFile: (NSString *)  filepath

Attemps to delete file in filepath from memory.

Parameters:
deleteFileNSString object representing filepath to the file to be deleted.

Definition at line 27 of file LocalDataHandler.m.

Here is the caller graph for this function:

+ (void) deleteFiles: (NSArray *)  filepaths

Attemps to delete files in filepaths from memory.

Parameters:
deleteFilesNSArray of NSString objects representing filepaths to files to be deleted.

Definition at line 44 of file LocalDataHandler.m.

Here is the caller graph for this function:

- (id) init [implementation]

Definition at line 17 of file LocalDataHandler.m.

- (int) int_cmp (const void *)  a
(const void *)  b 
[implementation]

Definition at line 247 of file LocalDataHandler.m.

Here is the caller graph for this function:

+ (NSMutableArray *) loadLocalScoresFromDefaultFile

Loads and returns previously saved LocalScoreDatas from default file.

Default file is 'catnip_local.data' in application's documents-folder.

Returns:
array of LocalScoreData objects. If no previously saved LocalScoreData objects are found, returns empty array.

Definition at line 121 of file LocalDataHandler.m.

Here is the caller graph for this function:

+ (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.

Parameters:
loadPlaylistsFromDefaultFileNSArray of all LocalScoreDatas saved in 'catnip_local.data'
Returns:
Constructed array of Playlist objects with references to LocalScoreData objects. If no previously saved Playlists are found returns empty array.

Definition at line 163 of file LocalDataHandler.m.

References Playlist::scorelist.

Here is the caller graph for this function:

+ (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.

Parameters:
removeAndDeleteCompositionDataArrayNSArray of CompositionData objects
fromScoreArrayNSArray of LocalScoreData objects
andDictionaryNSDictionary in form made by createComposerDictionary:
andPlaylistArrayNSArray of Playlist objects

Definition at line 601 of file LocalDataHandler.m.

References deleteFiles:, removeCompositionDataArray:fromDictionary:, removeScoreDataArray:fromPlaylistArray:, and removeScoreDataArray:fromScoreArray:.

Here is the call graph for this function:

Here is the caller graph for this function:

+ (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.

Parameters:
removeAndDeleteLocalScoreDataLocalScoreData object to be deleted
fromScoreArrayNSArray of LocalScoreData objects
andDictionaryNSDictionary in form made by createComposerDictionary:
andPlaylistArrayNSArray of Playlist objects

Definition at line 466 of file LocalDataHandler.m.

References deleteFile:, removeLocalScoreData:fromDictionary:, removeLocalScoreData:fromPlaylistArray:, and removeLocalScoreData:fromScoreArray:.

Here is the call graph for this function:

Here is the caller graph for this function:

+ (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.

Parameters:
removeAndDeleteScoreDataArrayNSArray of LocalScoreData objects
fromScoreArrayNSArray of LocalScoreData objects
andDictionaryNSDictionary in form made by createComposerDictionary:
andPlaylistArrayNSArray of Playlist objects

Definition at line 540 of file LocalDataHandler.m.

References removeAndDeleteLocalScoreData:fromScoreArray:andDictionary:andPlaylistArray:.

Here is the call graph for this function:

Here is the caller graph for this function:

+ (void) removeCompositionDataArray: (NSArray *)  cdarray
fromDictionary: (NSMutableDictionary *)  dict 

Removes references to scores in CompositionData array from dictionary.

Parameters:
removeCompositionDataArrayNSArray of CompositionData objects
fromDictionaryNSDictionary in form made by createComposerDictionary:

Definition at line 568 of file LocalDataHandler.m.

References CompositionData::musicScores, and removeScoreDataArray:fromDictionary:.

Here is the call graph for this function:

Here is the caller graph for this function:

+ (void) removeCompositionDataArray: (NSArray *)  cdarray
fromPlaylistArray: (NSMutableArray *)  parray 

Removes references to scores in CompositionData array from playlist arrays scorelists.

Parameters:
removeCompositionDataArrayNSArray of CompositionData objects
fromPlaylistArrayNSArray of Playlist objects

Definition at line 583 of file LocalDataHandler.m.

References CompositionData::musicScores, and removeScoreDataArray:fromPlaylistArray:.

Here is the call graph for this function:

+ (void) removeCompositionDataArray: (NSArray *)  cdarray
fromScoreArray: (NSMutableArray *)  sarray 

Removes references to scores in CompositionData array from score array.

Parameters:
removeCompositionDataArrayNSArray of CompositionData objects
fromScoreArrayNSArray of LocalScoreData objects

Definition at line 553 of file LocalDataHandler.m.

References CompositionData::musicScores, and removeScoreDataArray:fromScoreArray:.

Here is the call graph for this function:

+ (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.

Parameters:
removeLocalScoreDatascore which references are to be removed
fromDictionarydictionary 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.

Here is the caller graph for this function:

+ (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.

Parameters:
removeLocalScoreDatascore which references are to be removed
fromPlaylistArrayarray of Playlist objects from which the references will be removed

Definition at line 450 of file LocalDataHandler.m.

References removeLocalScoreData:fromScoreArray:.

Here is the call graph for this function:

Here is the caller graph for this function:

+ (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.

Parameters:
removeLocalScoreDatascore which references are to be removed
fromScoreArrayarray of LocalScoreData objects from which the references will be removed

Definition at line 371 of file LocalDataHandler.m.

References ScoreData::pdf.

Here is the caller graph for this function:

+ (void) removeScoreDataArray: (NSArray *)  sdarray
fromDictionary: (NSMutableDictionary *)  dict 

Removes references to scores in LocalScoreData array from dictionary.

Parameters:
removeScoreDataArrayNSArray of LocalScoreData objects
fromDictionaryNSDictionary in form made by createComposerDictionary:

Definition at line 495 of file LocalDataHandler.m.

References removeLocalScoreData:fromDictionary:.

Here is the call graph for this function:

Here is the caller graph for this function:

+ (void) removeScoreDataArray: (NSArray *)  sdarray
fromPlaylistArray: (NSMutableArray *)  parray 

Removes references to scores in LocalScoreData array from playlist array's scorelists.

Parameters:
removeScoreDataArrayNSArray of LocalScoreData objects
fromPlaylistArrayNSArray of Playlist objects

Definition at line 509 of file LocalDataHandler.m.

Here is the caller graph for this function:

+ (void) removeScoreDataArray: (NSArray *)  sdarray
fromScoreArray: (NSMutableArray *)  sarray 

Removes references to scores in LocalScoreData array from score array.

Parameters:
removeScoreDataArrayNSArray of LocalScoreData objects
fromScoreArrayNSArray of LocalScoreData objects

Definition at line 481 of file LocalDataHandler.m.

References removeLocalScoreData:fromScoreArray:.

Here is the call graph for this function:

Here is the caller graph for this function:

+ (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.

Here is the caller graph for this function:

+ (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.

Here is the caller graph for this function:

+ (BOOL) scoreArray: (NSArray *)  sarray
hasScoreWithPdfFileName: (NSString *)  filename 

Searchs if given score array has score with same pdf filename as given parameter.

Parameters:
scoreArrayNSArray of LocalScoreData objects
hasScoreWithPdfFileNamepdf-filename to search from scoreArray
Returns:
YES is match is found. NO otherwise.

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.

Parameters:
scoreArrayNSArray of LocalScoreData objects
hasScoreWithPdfFileNamefilepath to pdf to search from scoreArray
Returns:
YES is match is found. NO otherwise.

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.

Parameters:
searchFreeIndexForScoresNSArray of LocalScoreData objects
Returns:
If given array is null or it's count is 0 returns 1. Otherwise returns first free positive integer which is not index for any of the LocalScoreData objects in given array. If something goes horribly wrong and R'lyeh is rising returns -1.

Definition at line 265 of file LocalDataHandler.m.

References int_cmp.

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Enumerations Enumerator Properties Defines