|
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
//
// EMSchema.h
// Emmoco
//
// Created by bob frankel on 8/7/11.
// Copyright 2011 Emmoco, Inc.. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "EMResourceValue.h"
typedef enum {
EMResourceAccessTypeRead = 1 << 0,
EMResourceAccessTypeWrite = 1 << 1,
EMResourceAccessTypeIndicate = 1 << 2,
} EMResourceAccessType;
@class EMResourceValue;
/**
* A set of meta-data describing a set of resources.
* Written by Bob Frankel and Carolyn Vaughan
*/
@interface EMSchema : NSObject {
}
/**
* Creates a EMResourceSchema instance from the contents of a file.
* @param fileName a file containing JSON content
* @return a newly created EMResourceSchema instance
*/
+ (EMSchema*)schemaFromFile:(NSString*)fileName;
/**
* Get the read/write/indicator access capabilities of a named resource
* @param resourceName a valid resource name in this schema
* @return an NSString containing the characters 'r', 'w', and 'i' as appropriate
* @exception UsageError the resource name is invalid
*/
- (EMResourceAccessType)accessForResource:(NSString*)resourceName;
/**
* Returns a sorted NSArray containing all application resource names in this schema
*/
- (NSArray*)applicationResources;
/**
* Get the parameters associated with a number type.
* @param type a valid number type name in this schema
* @return a four-element NSArray holding the min, max, step, and prec parameters of this type
* @exception UsageError the number type name is invalid
*/
- (NSArray*)numberParametersForType:(NSString*)type;
/**
* Get the representation type associated with a number type.
* @param type a valid number type name in this schema
* @return an integral representation type
* @exception UsageError the number type name is invalid
*/
- (NSString*)numericRepresentationForType:(NSString*)type;
/**
* Get the values associated with an enum type.
* @param type a valid enum type name in this schema
* @return a NSDictionary containing enum value names and their corresponding ordinal
* @exception UsageError the enum type name is invalid
*/
- (NSDictionary*)enumValuesForType:(NSString*)type;
/**
* Get the names of the fields associated with a struct type.
* @param type a valid struct type name in this schema
* @return a NSArray containing field names
* @exception UsageError the struct type name is invalid
*/
- (NSArray*)fieldNamesForType:(NSString*)type;
/**
* Get the fields associated with a struct type.
* @param type a valid struct type name in this schema
* @return a NSDictionary containing field names and their corresponding type code
* @exception UsageError the struct type name is invalid
*/
- (NSDictionary*)fieldsForType:(NSString*)type;
/**
* Get the length of this string type.
* @param type a valid string type name in this schema
* @return the length of this string type
* @exception UsageError the string type name is invalid
*/
- (int)stringLengthForType:(NSString*)type;
/**
* Returns the fully-qualified name of this schema.
*/
- (NSString*)name;
/**
* Returns the protocol level of this schema
*/
- (int)protocolLevel;
/**
* Returns an NSDictionary containing all resource names in this schema and their corresponding type code.
*/
- (NSDictionary*)resources;
/**
* Returns the maximum size in bytes amongst all resource types in this schema.
*/
- (int)maxResourceSize;
/**
* Get the alignment of a named resource
* @param resourceName a named resource in this schema
* @return the alignment in bytes of this resource
* @exception UsageError the resource name is invalid
*/
- (int)byteAlignmentForResource:(NSString*)resourceName;
/**
* Get the unique id associated with a named resource
* @param resourceName a named resource in this schema
* @return the corresponding resource id
* @exception UsageError the resource name is invalid
*/
- (int)idForResource:(NSString*)resourceName;
/**
* Get the resource name associated with this resource id
* @param resourceId a resource id
* @return the corresponding resource name
* @exception UsageError the resource id is invalid
* @see idForResource:
*/
- (NSString*)nameForResourceWithID:(NSInteger)resourceId;
/**
* Get the size of a named resource
* @param resourceName a named resource in this schema
* @return the size in bytes of this resource
* @exception UsageError the resource name is invalid
*/
- (int)sizeForResourceNamed:(NSString*)resourceName;
/**
* Get the size of a standard scalar type
* @param type a scalar type code
* @return the size in bytes of this standard type
* @exception UsageError the type code is invalid
*/
- (int)sizeForStandardType:(NSString*)type;
/**
* Get the alignment of a standard scalar type
* @param type a scalar type code
* @return the alignment in bytes of this standard type
* @exception UsageError the type code is invalid
*/
- (int)alignmentForStandardType:(NSString*)type;
/**
* Returns a sorted NSArray containing all system resource names in this schema
*/
- (NSArray*)systemResources;
/**
* Get the type of a named resource
* @param resourceName the name of a resource in this schema
* @return the type code associated with this resource
* @exception UsageError the resource name is invalid
*/
- (NSString*)typeOfResourceNamed:(NSString*)resourceName;
/**
* Returns the owner of the schema definition this schema was created from.
*/
- (NSString*)owner;
/**
* Returns the version of the schema definition this schema was created from.
*/
- (NSString*)version;
/**
* Returns the description associated with this schema.
*/
- (NSString*)schemaDescription;
/**
* Returns the UUID associated with this schema.
*/
- (NSString*)UUID;
/**
* Returns the UUID associated with this schema as an array of numbers.
*/
- (NSArray *)numericalUUID;
/**
* Returns the build number associated with this schema as an array of numbers.
*/
- (NSArray *)buildDate;
/**
* Returns the schema hash associated with this schema as an array of numbers.
*/
- (NSArray *)schemaHash;
/**
* Returns the name of the resource that is being broadcast in the advertising packets. Returns nil if none.
*/
-(NSString *)broadcastResourceName;
/**
* Create a new ResourceValue instance for a named resource.
* @param resourceName a named resource in this schema
* @return a newly created EMResourceValue to a value for this resource
* @exception UsageError the resource name is invalid
*/
- (EMResourceValue*)newResourceValueForResourceNamed:(NSString*)resourceName;
/*
* TODO - fill in this documentation
*/
- (BOOL)validateResourceNamed:(NSString*)resourceName withAccess:(EMResourceAccessType)access;
-(NSNumber *)embeddedProtocolNumber;
-(int)packedSizeForType:(NSString*)type;
-(int)unpackedSizeForType:(NSString*)type;
-(NSArray *)fieldPackingsForType:(NSString*)type;
@end
|