]> err.no Git - sope/blob - sope-appserver/NGObjWeb/SoObjects/SoLookupAssociation.m
fixed various warnings
[sope] / sope-appserver / NGObjWeb / SoObjects / SoLookupAssociation.m
1 /*
2   Copyright (C) 2000-2004 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
5
6   OGo is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21
22 #include "SoLookupAssociation.h"
23 #include "SoObject.h"
24 #include <NGObjWeb/WOComponent.h>
25 #include "common.h"
26
27 @implementation SoLookupAssociation
28
29 + (int)version {
30   return [super version] /* v2 */;
31 }
32 + (void)initialize {
33   NSAssert2([super version] == 2,
34             @"invalid superclass (%@) version %i !",
35             NSStringFromClass([self superclass]), [super version]);
36 }
37
38 - (id)initWithTraversalPath:(NSArray *)_tp acquire:(BOOL)_ac {
39   if ((self = [super init])) {
40     self->traversalPath = [_tp copy];
41     self->acquire = _ac;
42   }
43   return self;
44 }
45
46 - (id)initWithString:(NSString *)_s {
47   BOOL acq;
48   
49   if ((acq = [_s hasPrefix:@"+"]))
50     _s = [_s substringFromIndex:1];
51   
52   return [self initWithTraversalPath:[_s pathComponents] acquire:acq];
53 }
54
55 - (void)dealloc {
56   [self->traversalPath release];
57   [super dealloc];
58 }
59
60 /* accessors */
61
62 - (NSArray *)traversalPath {
63   return self->traversalPath;
64 }
65 - (BOOL)doesAcquire {
66   return self->acquire;
67 }
68
69 /* value */
70
71 - (BOOL)isValueConstant {
72   return NO;
73 }
74 - (BOOL)isValueSettable {
75   return NO;
76 }
77
78 /* op */
79
80 - (void)setValue:(id)_value inComponent:(WOComponent *)_component {
81   // not settable
82   [NSException raise:@"AssociationException"
83                format:@"association value is not settable !"];
84 }
85
86 - (id)valueInComponent:(WOComponent *)_component {
87   return [_component traversePathArray:self->traversalPath 
88                      acquire:self->acquire];
89 }
90
91 @end /* SoLookupAssociation */