PageRenderTime 26ms CodeModel.GetById 19ms RepoModel.GetById 0ms 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
Possible License(s): Apache-2.0, BSD-3-Clause, GPL-2.0
  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. #import <Foundation/Foundation.h>
  15. @class KSTicket;
  16. // Encapsulates a persistent storage mechanism for saving and retrieving
  17. // KSTicket objects. Tickets are indexed by their productID, so no two tickets
  18. // can exist in the same store with the same productID. Tickets are indexed in a
  19. // case insensitive but case preserving manner: a ticket stored with a product
  20. // ID of "foo" could be replaced by a ticket with a product ID of "Foo". If a
  21. // ticket is stored and another ticket is already stored with the same
  22. // productID, then the new ticket replaces the previously stored one.
  23. @interface KSTicketStore : NSObject {
  24. @private
  25. NSString *path_;
  26. }
  27. // Returns a ticket store stored at |path|.
  28. + (id)ticketStoreWithPath:(NSString *)path;
  29. // Designated initializer.
  30. - (id)initWithPath:(NSString *)path;
  31. // Returns the path where this ticket store is stored.
  32. - (NSString *)path;
  33. // Returns the number of tickets currently stored.
  34. - (int)ticketCount;
  35. // Returns all tickets.
  36. - (NSArray *)tickets;
  37. // Returns the ticket associated with |productID|.
  38. - (KSTicket *)ticketForProductID:(NSString *)productID;
  39. // Returns YES if |ticket| was successfully added to the store. The stored
  40. // ticket is indexed by a lower-case version of its product ID. So storing
  41. // a ticket with a product ID of "Foo" would replace a previously stored ticket
  42. // with a product ID of "foo".
  43. - (BOOL)storeTicket:(KSTicket *)ticket;
  44. // Returns YES if |ticket| was successfully removed form the store.
  45. - (BOOL)deleteTicket:(KSTicket *)ticket;
  46. // Returns YES if the ticket identified by |productID| was removed from the store.
  47. - (BOOL)deleteTicketForProductID:(NSString *)productID;
  48. @end
  49. // A category to group methods that are related to querying an array for tickets
  50. // that match a certain criteria. In addition to the methods specified here, you
  51. // can also use the -[KSTicketStore tickets] method to get all of the tickets,
  52. // then use -[NSArray filteredArrayUsingPredicate:].
  53. @interface NSArray (TicketRetrieving)
  54. // Returns a dictionary that groups tickets by their server URL. The keys in the
  55. // dictionary are NSURLs, and the values are arrays of tickets that use that
  56. // server URL. This method must only be called on an homogeneous array of
  57. // KSTickets.
  58. - (NSDictionary *)ticketsByURL;
  59. @end