source: branches/CoreData/SapphireFrappliance/MetaData/Support/SapphireMetaDataSupport.h @ 801

Revision 801, 3.3 KB checked in by gbooker, 5 years ago (diff)

Added mechanism for another process to send changes to the primary holder of the db. This gets around the multiple writers problem in Core Data. Also added test mechanism as well as adding XML import to the helper.

Line 
1/*
2 * SapphireMetaDataSupport.h
3 * Sapphire
4 *
5 * Created by Graham Booker on Apr. 16, 2008.
6 * Copyright 2008 Sapphire Development Team and/or www.nanopi.net
7 * All rights reserved.
8 *
9 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
10 * General Public License as published by the Free Software Foundation; either version 3 of the License,
11 * or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
14 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
15 * Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with this program; if not,
18 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 */
20
21@class SapphireMetaDataUpgrading;
22
23NSString *searchCoverArtExtForPath(NSString *path);
24
25/*!
26 * @brief The basic support class
27 *
28 * This class contains many of the support functions necessary for operation.
29 */
30@interface SapphireMetaDataSupport : NSObject {
31        NSTimer                 *writeTimer;            /*!< @brief The timer to agregate writes*/
32        NSTimeInterval  interval;                       /*!< @brief The write interval*/
33        BOOL                    locked;                         /*!< @brief Was the DB locked during the last save*/
34}
35
36/*!
37 * @brief Prune unused parts of the metadata
38 *
39 * This function first prunes movies with no files, then any cast, genres, and directors with no movies.
40 * Then, it does the same with Episodes, followed by Seasons and TV Shows
41 *
42 * @param moc The context to prune
43 */
44+ (void)pruneMetaData:(NSManagedObjectContext *)moc;
45
46/*!
47 * @brief Save the context
48 *
49 * @param context The context to save
50 * @return YES if the save succeeded, NO otherwise
51 */
52+ (BOOL)save:(NSManagedObjectContext *)context;
53
54/*!
55 * @brief Was the DB locked in last save?
56 *
57 * @return YES if it was locked, NO otherwise
58 */
59+ (BOOL)wasLocked;
60
61/*!
62 * @brief Import the old plist into the context
63 *
64 * @param v1Context The context to use for old objects
65 * @param context The context to use for new objects
66 * @param display The display for UI feedback
67 */
68+ (void)importV1Store:(NSManagedObjectContext *)v1Context intoContext:(NSManagedObjectContext *)context withDisplay:(SapphireMetaDataUpgrading *)display;
69
70/*!
71 * @brief Import the old plist into the context
72 *
73 * @param configDir The directory containing old configuration files
74 * @param context The context to use for new objects
75 * @param display The display for UI feedback
76 */
77+ (void)importPlist:(NSString *)configDir intoContext:(NSManagedObjectContext *)context withDisplay:(SapphireMetaDataUpgrading *)display;
78
79/*!
80 * @brief Get the path for the collection art
81 *
82 * @return The base collection art path
83 */
84+ (NSString *)collectionArtPath;
85
86/*!
87 * @brief Get a dictionary describing all the changes in the context for sending to another location
88 *
89 * @param moc The context with changes
90 * @return The dictionary with the changes
91 */
92+ (NSDictionary *)changesDictionaryForContext:(NSManagedObjectContext *)moc;
93
94/*!
95 * @brief Apply a dictionary containing changes to the context
96 *
97 * @param changes The dictionary with the changes
98 * @param moc The to apply context with changes
99 */
100+ (void)applyChanges:(NSDictionary *)changes toContext:(NSManagedObjectContext *)moc;
101@end
Note: See TracBrowser for help on using the repository browser.