root/branches/CoreData/SapphireFrappliance/MetaData/Support/SapphireMetaDataSupport.h @ 840

Revision 840, 4.0 KB (checked in by gbooker, 16 months ago)

Delete unused objects as they become unused so as to not need the prune call later. This will help accelerate things later. Also, handled XML a bit better.

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        NSManagedObjectContext  *mainMoc;                       /*!< @brief The main context*/
32        NSTimer                                 *writeTimer;            /*!< @brief The timer to agregate writes*/
33        NSTimeInterval                  interval;                       /*!< @brief The write interval*/
34        BOOL                                    locked;                         /*!< @brief Was the DB locked during the last save*/
35}
36
37/*!
38 * @brief Prune unused parts of the metadata
39 *
40 * This function first prunes movies with no files, then any cast, genres, and directors with no movies.
41 * Then, it does the same with Episodes, followed by Seasons and TV Shows
42 *
43 * @param moc The context to prune
44 */
45+ (void)pruneMetaData:(NSManagedObjectContext *)moc;
46
47/*!
48 * @brief Sets an object up for pending delete
49 *
50 * Any object added to this set will be first checked before delete.  The check is calling selector
51 * shouldDelete and if returns YES, performs the delete, otherwise it is removed from set.
52 *
53 * @param objectToDelete The object to delete
54 */
55+ (void)setObjectForPendingDelete:(NSManagedObject *)objectToDelete;
56
57/*!
58 * @brief Save the context
59 *
60 * @param context The context to save
61 * @return YES if the save succeeded, NO otherwise
62 */
63+ (BOOL)save:(NSManagedObjectContext *)context;
64
65/*!
66 * @brief Save changes in a context in the main context
67 *
68 * @param context The context with changes to save
69 */
70+ (void)applyChangesFromContext:(NSManagedObjectContext *)context;
71
72/*!
73 * @brief Sets the main context
74 *
75 * @param moc the main context
76 */
77+ (void)setMainContext:(NSManagedObjectContext *)moc;
78
79/*!
80 * @brief Was the DB locked in last save?
81 *
82 * @return YES if it was locked, NO otherwise
83 */
84+ (BOOL)wasLocked;
85
86/*!
87 * @brief Import the old plist into the context
88 *
89 * @param v1Context The context to use for old objects
90 * @param context The context to use for new objects
91 * @param display The display for UI feedback
92 */
93+ (void)importV1Store:(NSManagedObjectContext *)v1Context intoContext:(NSManagedObjectContext *)context withDisplay:(SapphireMetaDataUpgrading *)display;
94
95/*!
96 * @brief Import the old plist into the context
97 *
98 * @param configDir The directory containing old configuration files
99 * @param context The context to use for new objects
100 * @param display The display for UI feedback
101 */
102+ (void)importPlist:(NSString *)configDir intoContext:(NSManagedObjectContext *)context withDisplay:(SapphireMetaDataUpgrading *)display;
103
104/*!
105 * @brief Get the path for the collection art
106 *
107 * @return The base collection art path
108 */
109+ (NSString *)collectionArtPath;
110
111/*!
112 * @brief Get a dictionary describing all the changes in the context for sending to another location
113 *
114 * @param moc The context with changes
115 * @return The dictionary with the changes
116 */
117+ (NSDictionary *)changesDictionaryForContext:(NSManagedObjectContext *)moc;
118
119/*!
120 * @brief Apply a dictionary containing changes to the context
121 *
122 * @param changes The dictionary with the changes
123 * @param moc The to apply context with changes
124 */
125+ (void)applyChanges:(NSDictionary *)changes toContext:(NSManagedObjectContext *)moc;
126@end
Note: See TracBrowser for help on using the browser.