From a2e4a4427d025a1c02578b11f2ce451917c84cbc Mon Sep 17 00:00:00 2001 From: helge Date: Thu, 4 Aug 2005 00:57:48 +0000 Subject: [PATCH] added KV archiving to rule engine some code cleanups git-svn-id: http://svn.opengroupware.org/SOPE/trunk@964 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-core/NGExtensions/ChangeLog | 9 +++++++++ .../EOExt.subproj/EOCompoundDataSource.m | 4 ++-- .../EOExt.subproj/EOFilterDataSource.m | 12 +++++++----- sope-core/NGExtensions/GNUmakefile.preamble | 2 +- sope-core/NGExtensions/NGExtensions/NGRule.h | 3 ++- .../NGExtensions/NGExtensions/NGRuleAssignment.h | 3 ++- .../NGExtensions/NGRuleEngine.subproj/NGRule.m | 15 ++++++++++++++- .../NGRuleEngine.subproj/NGRuleAssignment.m | 11 +++++++++++ sope-core/NGExtensions/Version | 2 +- 9 files changed, 49 insertions(+), 12 deletions(-) diff --git a/sope-core/NGExtensions/ChangeLog b/sope-core/NGExtensions/ChangeLog index c811b782..5fd5e6c8 100644 --- a/sope-core/NGExtensions/ChangeLog +++ b/sope-core/NGExtensions/ChangeLog @@ -1,3 +1,12 @@ +2005-08-04 Helge Hess + + * EOFilterDataSource.m, EOCompoundDataSource.m: code cleanups + (v4.5.168) + +2005-08-03 Helge Hess + + * added EOKeyValueArchiving support to NGRuleEngine objects (v4.5.167) + 2005-07-22 Helge Hess * FdExt.subproj/NSException+misc.m: added -isException and diff --git a/sope-core/NGExtensions/EOExt.subproj/EOCompoundDataSource.m b/sope-core/NGExtensions/EOExt.subproj/EOCompoundDataSource.m index 9f685f25..1a1fd9ce 100644 --- a/sope-core/NGExtensions/EOExt.subproj/EOCompoundDataSource.m +++ b/sope-core/NGExtensions/EOExt.subproj/EOCompoundDataSource.m @@ -259,10 +259,10 @@ return [[[self sources] objectAtIndex:0] classDescriptionForObjects]; e = [[self sources] objectEnumerator]; - while ((ds = [e nextObject])) { + while ((ds = [e nextObject]) != nil) { EOClassDescription *cd; - if ((cd = [ds classDescriptionForObjects])) + if ((cd = [ds classDescriptionForObjects]) != nil) return cd; } /* all datasources failed to create .. */ diff --git a/sope-core/NGExtensions/EOExt.subproj/EOFilterDataSource.m b/sope-core/NGExtensions/EOExt.subproj/EOFilterDataSource.m index 154244db..cac5719b 100644 --- a/sope-core/NGExtensions/EOExt.subproj/EOFilterDataSource.m +++ b/sope-core/NGExtensions/EOExt.subproj/EOFilterDataSource.m @@ -202,13 +202,14 @@ ms = [NSMutableString stringWithCapacity:64]; [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])]; - if (self->source) [ms appendFormat:@" source=%@", self->source]; - if (self->auxiliaryQualifier) + if (self->source != nil) + [ms appendFormat:@" source=%@", self->source]; + if (self->auxiliaryQualifier != nil) [ms appendFormat:@" qualifier=%@", self->auxiliaryQualifier]; - if (self->sortOrderings) + if (self->sortOrderings != nil) [ms appendFormat:@" orderings=%@", self->sortOrderings]; - if (self->groupings) - [ms appendFormat:@" groupings=%@", self->sortOrderings]; + if (self->groupings != nil) + [ms appendFormat:@" groupings=%@", self->groupings]; [ms appendString:@">"]; return ms; @@ -216,6 +217,7 @@ @end /* EOFilterDataSource */ + @implementation NSDictionary(EOFilterDataSource) - (NSArray *)flattenedArrayWithHint:(unsigned int)_hint diff --git a/sope-core/NGExtensions/GNUmakefile.preamble b/sope-core/NGExtensions/GNUmakefile.preamble index 19c8a805..377cca8b 100644 --- a/sope-core/NGExtensions/GNUmakefile.preamble +++ b/sope-core/NGExtensions/GNUmakefile.preamble @@ -1,4 +1,4 @@ -# $Id$ +# compilation settings ADDITIONAL_CPP_FLAGS += -Wall -Wno-import -Wno-protocol -O2 libNGExtensions_INCLUDE_DIRS += -I.. diff --git a/sope-core/NGExtensions/NGExtensions/NGRule.h b/sope-core/NGExtensions/NGExtensions/NGRule.h index 03f63064..6ab33b7a 100644 --- a/sope-core/NGExtensions/NGExtensions/NGRule.h +++ b/sope-core/NGExtensions/NGExtensions/NGRule.h @@ -23,6 +23,7 @@ #define __NGRuleEngine_NGRule_H__ #import +#include /* NGRule @@ -43,7 +44,7 @@ @class EOQualifier; -@interface NGRule : NSObject +@interface NGRule : NSObject < EOKeyValueArchiving > { EOQualifier *qualifier; id action; diff --git a/sope-core/NGExtensions/NGExtensions/NGRuleAssignment.h b/sope-core/NGExtensions/NGExtensions/NGRuleAssignment.h index b2fdc803..b3c2d712 100644 --- a/sope-core/NGExtensions/NGExtensions/NGRuleAssignment.h +++ b/sope-core/NGExtensions/NGExtensions/NGRuleAssignment.h @@ -23,6 +23,7 @@ #define __NGRuleEngine_NGRuleAssignment_H__ #import +#include /* NGRuleAssignment @@ -39,7 +40,7 @@ @class NSString; -@interface NGRuleAssignment : NSObject +@interface NGRuleAssignment : NSObject < EOKeyValueArchiving > { NSString *keyPath; id value; diff --git a/sope-core/NGExtensions/NGRuleEngine.subproj/NGRule.m b/sope-core/NGExtensions/NGRuleEngine.subproj/NGRule.m index b5bf458e..be742032 100644 --- a/sope-core/NGExtensions/NGRuleEngine.subproj/NGRule.m +++ b/sope-core/NGExtensions/NGRuleEngine.subproj/NGRule.m @@ -1,5 +1,5 @@ /* - Copyright (C) 2003-2004 SKYRIX Software AG + Copyright (C) 2003-2005 SKYRIX Software AG This file is part of SOPE. @@ -103,6 +103,19 @@ return [self->action fireInContext:_ctx]; } +/* key/value archiving */ + +- (id)initWithKeyValueUnarchiver:(EOKeyValueUnarchiver *)_unarchiver { + return [self initWithQualifier:[_unarchiver decodeObjectForKey:@"lhs"] + action:[_unarchiver decodeObjectForKey:@"rhs"] + priority:[_unarchiver decodeIntForKey:@"author"]]; +} +- (void)encodeWithKeyValueArchiver:(EOKeyValueArchiver *)_archiver { + [_archiver encodeInt:[self priority] forKey:@"author"]; + [_archiver encodeObject:[self qualifier] forKey:@"lhs"]; + [_archiver encodeObject:[self action] forKey:@"rhs"]; +} + /* representations */ - (NSString *)stringValue { diff --git a/sope-core/NGExtensions/NGRuleEngine.subproj/NGRuleAssignment.m b/sope-core/NGExtensions/NGRuleEngine.subproj/NGRuleAssignment.m index 6d98431e..13e54536 100644 --- a/sope-core/NGExtensions/NGRuleEngine.subproj/NGRuleAssignment.m +++ b/sope-core/NGExtensions/NGRuleEngine.subproj/NGRuleAssignment.m @@ -74,6 +74,17 @@ return self->value; } +/* key/value archiving */ + +- (id)initWithKeyValueUnarchiver:(EOKeyValueUnarchiver *)_unarchiver { + return [self initWithKeyPath:[_unarchiver decodeObjectForKey:@"keyPath"] + value:[_unarchiver decodeObjectForKey:@"value"]]; +} +- (void)encodeWithKeyValueArchiver:(EOKeyValueArchiver *)_archiver { + [_archiver encodeObject:[self keyPath] forKey:@"keyPath"]; + [_archiver encodeObject:[self value] forKey:@"value"]; +} + /* description */ - (NSString *)valueStringValue { diff --git a/sope-core/NGExtensions/Version b/sope-core/NGExtensions/Version index b4066c65..406c7817 100644 --- a/sope-core/NGExtensions/Version +++ b/sope-core/NGExtensions/Version @@ -1,6 +1,6 @@ # version -SUBMINOR_VERSION:=166 +SUBMINOR_VERSION:=168 # v4.3.115 requires libFoundation v1.0.59 # v4.2.72 requires libEOControl v4.2.39 -- 2.39.5