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

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

http://macfuse.googlecode.com/
C++ Header | 91 lines | 28 code | 21 blank | 42 comment | 0 complexity | 02f17453410969b8503b23f0be935968 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// An abstract class that encapsulates the ability to check for the existence
18// of something. Concrete subclasses may provide the ability to check existence
19// by stating a path, asking LaunchServices whether an application with a
20// specific bundle ID exists, or running a Spotlight query. 
21@interface KSExistenceChecker : NSObject <NSCoding>
22
23// Returns an existence checker whose -exists method always returns NO. Useful 
24// for testing.
25+ (id)falseChecker;
26
27// Returns an existence checker whose -exists method always returns
28// YES. This is useful for in-application users who don't really need
29// an existence check, such as an updater helper tool inside of an
30// application bundle.  Since the tool exists and is running, the
31// application obviously exists too.
32+ (id)trueChecker;
33
34// Subclasses must override this method. It should return YES if the represented
35// object exists, NO otherwise.
36- (BOOL)exists;
37
38@end
39
40
41//
42// Concrete subclasses 
43//
44
45
46// Existence checker for checking the existence of a path.
47@interface KSPathExistenceChecker : KSExistenceChecker {
48 @private
49  NSString *path_;
50}
51
52// Returns an existence checker that will check the existence of |path|.
53+ (id)checkerWithPath:(NSString *)path;
54- (id)initWithPath:(NSString *)path;
55
56// Returns the existence checker's path.
57- (NSString *)path;
58
59@end
60
61
62// Existence checker for querying LaunchServices about the existence of an
63// application with the specified bundle ID.
64@interface KSLaunchServicesExistenceChecker : KSExistenceChecker {
65 @private
66  NSString *bundleID_;
67}
68
69// Returns an existence checker that will check for the existence of |bid| in 
70// the LaunchServices database.
71+ (id)checkerWithBundleID:(NSString *)bid;
72- (id)initWithBundleID:(NSString *)bid;
73
74@end
75
76
77// Existence checker that queries Spotlight. If Spotlight returns any results, 
78// the existence check will be YES, if Spotlight doesn't find anything, the
79// existence check will be NO. It does not matter /what/ is found, just that 
80// something is found.
81@interface KSSpotlightExistenceChecker : KSExistenceChecker {
82 @private
83  NSString *query_;
84}
85
86// Returns an existence checker that will use Spotlight to see if |query| 
87// returns any results.
88+ (id)checkerWithQuery:(NSString *)query;
89- (id)initWithQuery:(NSString *)query;
90
91@end