Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Neaten and simplify some code.

git-svn-id: svn+voltron://voltron/data/svn/MarcoPolo/trunk@847 a27563e6-5939-db11-9576-004854876331
  • Loading branch information...
commit 0f0fab6b05f632a93aba8e114aa98b1c8d49a2af 1 parent 0a8e58d
ds authored
4 src/EvidenceSource.h
View
@@ -50,14 +50,11 @@
- (void)stop;
// To be implemented by descendant classes:
-// TODO: some of these could be class methods
- (NSString *)name;
- (BOOL)doesRuleMatch:(NSDictionary *)rule;
// Optionally implemented by descendant classes
-- (NSArray *)getSuggestions; // NSArray of NSDictionary: keys are type, parameter, description
- (NSArray *)typesOfRulesMatched; // optional; default is [self name]
-- (NSString *)getSuggestionLeadText:(NSString *)type; // optional; default is "The presence of"
@end
@@ -72,7 +69,6 @@
- (EvidenceSource *)sourceWithName:(NSString *)name;
- (void)startOrStopAll;
- (BOOL)ruleMatches:(NSDictionary *)rule;
-- (NSArray *)getSuggestionsFromSource:(NSString *)name ofType:(NSString *)type; // type may be nil
- (NSEnumerator *)sourceEnumerator;
// NSMenu delegates (for adding rules)
54 src/EvidenceSource.m
View
@@ -222,15 +222,19 @@ - (void)writeToPanel:(NSDictionary *)dict usingType:(NSString *)type
#pragma mark -
-- (void)notImplemented:(NSString *)methodName
+- (void)start
{
- [NSException raise:@"Abstract Class Exception"
- format:[NSString stringWithFormat:@"Error, -%@ not implemented.", methodName]];
+ [self doesNotRecognizeSelector:_cmd];
+}
+
+- (void)stop
+{
+ [self doesNotRecognizeSelector:_cmd];
}
- (NSString *)name
{
- [self notImplemented:@"name"];
+ [self doesNotRecognizeSelector:_cmd];
return nil;
}
@@ -241,31 +245,10 @@ - (NSArray *)typesOfRulesMatched
- (BOOL)doesRuleMatch:(NSDictionary *)rule
{
- [self notImplemented:@"doesRuleMatch"];
+ [self doesNotRecognizeSelector:_cmd];
return NO;
}
-- (NSString *)getSuggestionLeadText:(NSString *)type
-{
- return NSLocalizedString(@"The presence of", @"In rule-adding dialog");
-}
-
-- (NSArray *)getSuggestions
-{
- [self notImplemented:@"getSuggestions"];
- return nil;
-}
-
-- (void)start
-{
- [self notImplemented:@"start"];
-}
-
-- (void)stop
-{
- [self notImplemented:@"stop"];
-}
-
@end
#pragma mark -
@@ -382,25 +365,6 @@ - (BOOL)ruleMatches:(NSDictionary *)rule
return NO;
}
-- (NSArray *)getSuggestionsFromSource:(NSString *)name ofType:(NSString *)type
-{
- EvidenceSource *src = [self sourceWithName:name];
-
- if (!type)
- return [src getSuggestions];
-
- NSMutableArray *suggestions = [NSMutableArray array];
- NSArray *s_arr = [src getSuggestions];
- NSEnumerator *s_en = [s_arr objectEnumerator];
- NSDictionary *s_dict;
- while ((s_dict = [s_en nextObject])) {
- if ([[s_dict valueForKey:@"type"] isEqualToString:type])
- [suggestions addObject:s_dict];
- }
-
- return suggestions;
-}
-
- (NSEnumerator *)sourceEnumerator
{
return [sources objectEnumerator];
4 src/GenericEvidenceSource.h
View
@@ -17,7 +17,7 @@
- (id)init;
// Need to be implemented by descendant classes
-//- (NSString *)getSuggestionLeadText:(NSString *)type;
-//- (NSArray *)getSuggestions;
+- (NSString *)getSuggestionLeadText:(NSString *)type;
+- (NSArray *)getSuggestions; // returns an NSArray of NSDictionary: keys are type, parameter, description
@end
12 src/GenericEvidenceSource.m
View
@@ -72,4 +72,16 @@ - (void)writeToPanel:(NSDictionary *)dict usingType:(NSString *)type
}
}
+- (NSString *)getSuggestionLeadText:(NSString *)type
+{
+ [self doesNotRecognizeSelector:_cmd];
+ return nil;
+}
+
+- (NSArray *)getSuggestions
+{
+ [self doesNotRecognizeSelector:_cmd];
+ return nil;
+}
+
@end
Please sign in to comment.
Something went wrong with that request. Please try again.