PageRenderTime 157ms CodeModel.GetById 113ms app.highlight 40ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/google-toolbox-for-mac/Xcode4Plugin/GTMXcodePluginManager.m

http://macfuse.googlecode.com/
Objective C | 100 lines | 66 code | 17 blank | 17 comment | 7 complexity | 8778abbaecae2ad80b1926f23bc1ca5a MD5 | raw file
  1//
  2//  GTMXcodePluginManager.m
  3//
  4//  Copyright 2007-2011 Google Inc.
  5//
  6//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
  7//  use this file except in compliance with the License.  You may obtain a copy
  8//  of the License at
  9//
 10//  http://www.apache.org/licenses/LICENSE-2.0
 11//
 12//  Unless required by applicable law or agreed to in writing, software
 13//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 14//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 15//  License for the specific language governing permissions and limitations under
 16//  the License.
 17//
 18
 19#import "GTMXcodePluginManager.h"
 20
 21#import <Cocoa/Cocoa.h>
 22
 23static NSMutableArray *gRegisteredClasses = nil;
 24static NSMutableArray *gPlugins = nil;
 25
 26@implementation GTMXcodePluginManager
 27+ (void)registerPluginClass:(Class)cls {
 28  @synchronized([self class]) {
 29    if (!gRegisteredClasses) {
 30      gRegisteredClasses = [[NSMutableArray alloc] init];
 31    }
 32    if (cls) {
 33      [gRegisteredClasses addObject:cls];
 34    }
 35  }
 36}
 37
 38+ (void)pluginDidLoad:(NSBundle *)bundle {
 39  gPlugins
 40      = [[NSMutableArray alloc] initWithCapacity:[gRegisteredClasses count]];
 41  for (Class cls in gRegisteredClasses) {
 42    GTMXcodePlugin *plugin = [[cls alloc] initWithBundle:bundle];
 43    if (plugin) {
 44      [gPlugins addObject:plugin];
 45    }
 46  }
 47
 48  [gRegisteredClasses release];
 49  gRegisteredClasses = nil;
 50
 51  NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
 52  [nc addObserver:self
 53         selector:@selector(applicationDidFinishLaunching:)
 54             name:NSApplicationDidFinishLaunchingNotification
 55           object:NSApp];
 56}
 57
 58+ (void)applicationDidFinishLaunching:(NSNotification *)notification {
 59  NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
 60  [nc removeObserver:self
 61                name:NSApplicationDidFinishLaunchingNotification
 62              object:NSApp];
 63  for (GTMXcodePlugin *plugin in gPlugins) {
 64    [plugin applicationDidFinishLaunching:notification];
 65  }
 66}
 67
 68+ (float)xCodeVersion {
 69  NSBundle *bundle = [NSBundle mainBundle];
 70  id object = [bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
 71  float value = [object floatValue];
 72  if (!(value > 0.0)) {
 73    NSLog(@"Unable to get Xcode Version");
 74  }
 75  return value;
 76}
 77
 78@end
 79
 80@implementation GTMXcodePlugin
 81
 82@synthesize bundle = bundle_;
 83
 84- (id)initWithBundle:(NSBundle *)bundle {
 85  if ((self = [super init])) {
 86    bundle_ = [bundle retain];
 87  }
 88  return self;
 89}
 90
 91- (void)dealloc {
 92  [bundle_ release];
 93  [super dealloc];
 94}
 95
 96- (void)applicationDidFinishLaunching:(NSNotification *)notification {
 97}
 98
 99@end
100