PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/update-engine/Core/KSTicketStore.h

http://macfuse.googlecode.com/
C++ Header | 75 lines | 19 code | 16 blank | 40 comment | 0 complexity | 682118e2140d87d00cc11e4fbe2db5e0 MD5 | raw file
 1// Copyright 2008 Google Inc.
 2//
 3// Licensed under the Apache License, Version 2.0 (the "License");
 4// you may not use this file except in compliance with the License.
 5// You may obtain a copy of the License at
 6//
 7//     http://www.apache.org/licenses/LICENSE-2.0
 8//
 9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#import <Foundation/Foundation.h>
16
17@class KSTicket;
18
19// Encapsulates a persistent storage mechanism for saving and retrieving
20// KSTicket objects. Tickets are indexed by their productID, so no two tickets 
21// can exist in the same store with the same productID. Tickets are indexed in a
22// case insensitive but case preserving manner: a ticket stored with a product 
23// ID of "foo" could be replaced by a ticket with a product ID of "Foo". If a 
24// ticket is stored and another ticket is already stored with the same 
25// productID, then the new ticket replaces the previously stored one.
26@interface KSTicketStore : NSObject {
27 @private
28  NSString *path_;
29}
30
31// Returns a ticket store stored at |path|.
32+ (id)ticketStoreWithPath:(NSString *)path;
33// Designated initializer.
34- (id)initWithPath:(NSString *)path;
35
36// Returns the path where this ticket store is stored.
37- (NSString *)path;
38
39// Returns the number of tickets currently stored.
40- (int)ticketCount;
41
42// Returns all tickets.
43- (NSArray *)tickets;
44
45// Returns the ticket associated with |productID|.
46- (KSTicket *)ticketForProductID:(NSString *)productID;
47
48// Returns YES if |ticket| was successfully added to the store. The stored
49// ticket is indexed by a lower-case version of its product ID. So storing
50// a ticket with a product ID of "Foo" would replace a previously stored ticket
51// with a product ID of "foo".
52- (BOOL)storeTicket:(KSTicket *)ticket;
53
54// Returns YES if |ticket| was successfully removed form the store.
55- (BOOL)deleteTicket:(KSTicket *)ticket;
56
57// Returns YES if the ticket identified by |productID| was removed from the store.
58- (BOOL)deleteTicketForProductID:(NSString *)productID;
59
60@end
61
62
63// A category to group methods that are related to querying an array for tickets
64// that match a certain criteria. In addition to the methods specified here, you
65// can also use the -[KSTicketStore tickets] method to get all of the tickets,
66// then use -[NSArray filteredArrayUsingPredicate:].
67@interface NSArray (TicketRetrieving)
68
69// Returns a dictionary that groups tickets by their server URL. The keys in the
70// dictionary are NSURLs, and the values are arrays of tickets that use that 
71// server URL. This method must only be called on an homogeneous array of
72// KSTickets.
73- (NSDictionary *)ticketsByURL;
74
75@end