summaryrefslogtreecommitdiff
path: root/tikzit/src/common/GraphElementProperty.h
blob: 029e7f3cb30b8567b403704759a302a1d920e4ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//
//  GraphElementProperty.h
//  TikZiT
//  
//  Copyright 2010 Aleks Kissinger. All rights reserved.
//  
//  
//  This file is part of TikZiT.
//  
//  TikZiT is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//  
//  TikZiT is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//  
//  You should have received a copy of the GNU General Public License
//  along with TikZiT.  If not, see <http://www.gnu.org/licenses/>.
//  

#import <Foundation/Foundation.h>

/*!
 @class GraphElementProperty
 @brief A property. I.e. a single entry in a node's/edge's/graph's 
        GraphElementData table.
 */
@interface GraphElementProperty : NSObject<NSCopying> {
	NSString *key;
	NSString *value;
	BOOL isAtom;
	BOOL isKeyMatch;
}

@property (readwrite,retain) NSString *key;
@property (readwrite,retain) NSString *value;
@property (readonly) BOOL isAtom;
@property (readonly) BOOL isKeyMatch;

/*!
 @brief      Initialize a new key-matching object.
 @param      k a key to match
 @result     A key-matching object.
 */
- (id)initWithKeyMatching:(NSString*)k;
+ (id)keyMatching:(NSString*)k;

/*!
 @brief      Initialize a new atomic property.
 @param      n the atom's name
 @result     An atom.
 */
- (id)initWithAtomName:(NSString*)n;
+ (id)atom:(NSString*)n;

/*!
 @brief      Initialize a new property.
 @param      v the property's value
 @param      k the associated key
 @result     A property.
 */
- (id)initWithPropertyValue:(NSString*)v forKey:(NSString*)k;
+ (id)property:(NSString*)k withValue:(NSString*)v;

/*!
 @brief      A matching function for properties.
 @details    Two properties match iff their keys match and one of the following:
             (a) they are both atomic, (b) one is a key-matching and one is a non-atomic
             property, or (c) they are both non-atomic and their values match.
 @param      object another GraphElementProperty
 @result     A boolean.
 */
- (BOOL)matches:(GraphElementProperty*)object;

/*!
 @brief      An alias for <tt>matches:</tt>. This allows one to use built-in methods that
             filter on <tt>isEqual:</tt> for <tt>NSObject</tt>s.
 @param      object another GraphElementProperty
 @result     A boolean.
 */
- (BOOL)isEqual:(id)object;

@end

// vi:ft=objc:noet:ts=4:sts=4:sw=4