/
GBModelBase.h
121 lines (87 loc) · 4.76 KB
/
GBModelBase.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//
// GBModelBase.h
// appledoc
//
// Created by Tomaz Kragelj on 28.7.10.
// Copyright (C) 2010, Gentle Bytes. All rights reserved.
//
#import <Foundation/Foundation.h>
@class GBComment;
@class GBSourceInfo;
/** Provides common functionality for model objects. */
@interface GBModelBase : NSObject {
@private
NSMutableSet *_sourceInfos;
NSMutableDictionary *_sourceInfosByFilenames;
}
///---------------------------------------------------------------------------------------
/// @name Declared files handling
///---------------------------------------------------------------------------------------
/** Registers the given `GBSourceInfo` to `sourceInfos` list.
If file data with the same filename already exists in the set, it is replaced with the given one.
@param data Source information data.
@exception NSException Thrown if the given filename is `nil` or empty.
*/
- (void)registerSourceInfo:(GBSourceInfo *)data;
/** Returns the array of all `sourceInfos` sorted by file name.
@see sourceInfos
@see registerSourceInfo:
@see prefferedSourceInfo
*/
- (NSArray *)sourceInfosSortedByName;
/** Returns the preffered source info that should be rendered to output.
This investigates `sourceInfos` list and `comment` and returns the most likely used one. If comment is given and has source information attached, that one is used. If comment is not given, source information list from the receiver is used. If header file is found in the list, that one is preffered. If header file is not found, the first file is returned.
@return Returns preffered source information object to be used for output.
@see sourceInfos
@see sourceInfosSortedByName
*/
@property (readonly) GBSourceInfo *prefferedSourceInfo;
/** The list of all declared file data as `GBSourceInfo` objects.
@see registerSourceInfo:
@see sourceInfosSortedByName
@see prefferedSourceInfo
*/
@property (readonly) NSSet *sourceInfos;
///---------------------------------------------------------------------------------------
/// @name Comments handling
///---------------------------------------------------------------------------------------
/** The comment associated with this object or `nil` if no comment is associated. */
@property (retain) GBComment *comment;
///---------------------------------------------------------------------------------------
/// @name Data handling
///---------------------------------------------------------------------------------------
/** Merges all data from the given object.
Source object is left unchanged. If the same object is passed in, nothing happens. Subclasses should override and add their own specifics, however they should send super object the message as well! Here's overriden method example:
- (void)mergeDataFromObject:(GBModelBase *)source {
// source data validation here...
[super mergeDataFromObject:source];
// merge custom data here...
}
@param source Source object to merge from.
*/
- (void)mergeDataFromObject:(id)source;
///---------------------------------------------------------------------------------------
/// @name Hierarchy handling
///---------------------------------------------------------------------------------------
/** Object's parent object or `nil` if object has no parent.
This is mostly used for more in-context logging messages.
*/
@property (retain) id parentObject;
/** Specifies whether this is a top level object or not.
Top level objects are classes, categories and protocols.
*/
@property (readonly) BOOL isTopLevelObject;
///---------------------------------------------------------------------------------------
/// @name Output generation helpers
///---------------------------------------------------------------------------------------
/** Returns the HTML reference for the object that can be used within the same HTML file.
This is simply a wrapper over `[GBApplicationSettingsProvider htmlReferenceForObject:fromSource:]`, passing the given object as both method arguments. The major reason for introducing this method is the ability to reference it from the output templates! In this way all knowledge about references is handled in a single point and doesn't have to be repeated in various places.
@see htmlReferenceName
*/
@property (copy) NSString *htmlLocalReference;
/** Returns the HTML reference name of the object that can be used as an anchor to link against.
This is simply a wrapper over `[GBApplicationSettingsProvider htmlReferenceNameForObject:]`, passing the given object as the method argument. The major reason for introducing this method is the ability to reference it from the output templates! In this way all knowledge about references is handled in a single point and doesn't have to be repeated in various places.
@see htmlLocalReference
*/
@property (copy) NSString *htmlReferenceName;
@end