PageRenderTime 32ms CodeModel.GetById 10ms app.highlight 19ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/update-engine/Common/KSAction.m

http://macfuse.googlecode.com/
Objective C | 93 lines | 54 code | 17 blank | 22 comment | 6 complexity | e6216b88c384578eabf94e12c5fd049f 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 "KSAction.h"
16#import "KSActionProcessor.h"
17#import "KSActionPipe.h"
18#import "GTMDefines.h"
19#import "GTMLogger.h"
20
21
22@implementation KSAction
23
24- (id)init {
25  if ((self = [super init])) {
26    [self setInPipe:nil];
27    [self setOutPipe:nil];
28  }
29  return self;
30}
31
32- (void)dealloc {
33  [processor_ release];
34  [inpipe_ release];
35  [outpipe_ release];
36  [super dealloc];
37}
38
39- (KSActionProcessor *)processor {
40  return [[processor_ retain] autorelease];
41}
42
43- (void)setProcessor:(KSActionProcessor *)processor {
44  [processor_ autorelease];
45  processor_ = [processor retain];
46}
47
48- (KSActionPipe *)inPipe {
49  return [[inpipe_ retain] autorelease];
50}
51
52- (void)setInPipe:(KSActionPipe *)inpipe {
53  [inpipe_ autorelease];
54  inpipe_ = [inpipe retain];
55  if (inpipe_ == nil)  // Never let inpipe be nil
56    inpipe_ = [[KSActionPipe alloc] init];
57}
58
59- (KSActionPipe *)outPipe {
60  return [[outpipe_ retain] autorelease];
61}
62
63- (void)setOutPipe:(KSActionPipe *)outpipe {
64  [outpipe_ autorelease];
65  outpipe_ = [outpipe retain];
66  if (outpipe_ == nil)  // Never let outpipe be nil
67    outpipe_ = [[KSActionPipe alloc] init];
68}
69
70- (BOOL)isRunning {
71  return [[self processor] currentAction] == self;
72}
73
74// COV_NF_START
75- (void)performAction {
76  // Subclasses must override this method, otherwise their actions will be
77  // useless.
78
79  // If this method is not overridden, we'll _GTMDevAssert so that debug builds
80  // break, but in Release builds we'll just log and tell the processor that
81  // we're done so it doesn't hang.
82
83  _GTMDevAssert(NO, @"-performAction: method not overridden");
84  [processor_ finishedProcessing:self successfully:NO];
85}
86// COV_NF_END
87
88- (void)terminateAction {
89  // Do nothing. Subclasses may optionally override this method if they need to
90  // do special cleanup when their action is being terminated.
91}
92
93@end