-
Notifications
You must be signed in to change notification settings - Fork 3
/
GCContext.h
65 lines (43 loc) · 1.57 KB
/
GCContext.h
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
//
// GCXRefStore.h
// Gedcom
//
// Created by Mikkel Eide Eriksen on 28/03/12.
// Copyright (c) 2012 Mikkel Eide Eriksen. All rights reserved.
//
#import <Foundation/Foundation.h>
@class GCEntity;
/**
A context provides lookup functionality related to xrefs.
*/
@interface GCContext : NSObject <NSCoding>
/// @name Obtaining a context
/// Creates a new context.
+ (id)context;
/// @name Translating Xrefs
/** Returns an xref for the given entity.
@param entity An entity.
@return If an xref exists for the entity, it is returned. Otherwise one is created and returned.
*/
- (NSString *)xrefForEntity:(GCEntity *)entity;
/** Returns the entity for an xref.
@param xref A string containing an xref.
@return If an entity exists for the xref, it is returned. Otherwise `nil` is returned.
*/
- (GCEntity *)entityForXref:(NSString *)xref;
/// @name Registering callbacks
/** Register a callback for an xref.
If an entity for the xref exists, the callback is issued immediately, otherwise it is saved until such a time as an entity exists.
@param xref A string containing an xref.
@param block A block that will be called as soon as an entity exists.
*/
- (void)registerBlock:(void (^)(NSString *xref))block forXref:(NSString *)xref;
/// @name Registering Xrefs
/** Stores an xref for an entity.
If a callback has been registered for the xref, it is issued.
Used during import from Gedcom data.
@param xref A string containing an xref.
@param entity An entity to be associated with the xref.
*/
- (void)setXref:(NSString *)xref forEntity:(GCEntity *)entity;
@end