gmsec 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +76 -0
- data/Rakefile +2 -0
- data/examples/example_publisher_config.xml +1609 -0
- data/examples/gm_msg_config +87 -0
- data/examples/gmconfig +57 -0
- data/examples/gmconfig.xml +45 -0
- data/examples/gmpub +76 -0
- data/gmsec.gemspec +29 -0
- data/lib/gmsec.rb +15 -0
- data/lib/gmsec/api.rb +157 -0
- data/lib/gmsec/config.rb +89 -0
- data/lib/gmsec/config_file.rb +64 -0
- data/lib/gmsec/connection.rb +208 -0
- data/lib/gmsec/definitions.rb +189 -0
- data/lib/gmsec/field.rb +231 -0
- data/lib/gmsec/message.rb +211 -0
- data/lib/gmsec/status.rb +30 -0
- data/lib/gmsec/version.rb +3 -0
- data/spec/gmsec/config_spec.rb +43 -0
- data/spec/gmsec/connection_spec.rb +12 -0
- data/spec/gmsec/field_spec.rb +82 -0
- data/spec/integration/connection_spec.rb +110 -0
- data/spec/spec_helper.rb +2 -0
- metadata +174 -0
data/lib/gmsec/config.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
class GMSEC::Config
|
2
|
+
extend GMSEC::API
|
3
|
+
|
4
|
+
has :status
|
5
|
+
|
6
|
+
bind :GMSEC_CONFIG_OBJECT do |pointer|
|
7
|
+
gmsec_CreateConfig(pointer, status)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.from_config_file(config_file, config_name)
|
11
|
+
config = config_file.get_config(config_name)
|
12
|
+
new(native_object: to_native(config))
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(options={})
|
16
|
+
options.each do |key, value|
|
17
|
+
add_value(key, value)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def [](key)
|
22
|
+
get_value(key)
|
23
|
+
end
|
24
|
+
|
25
|
+
def []=(key, value)
|
26
|
+
add_value(key, value)
|
27
|
+
end
|
28
|
+
|
29
|
+
def values
|
30
|
+
Enumerator.new do |y|
|
31
|
+
field = GMSEC::Field.new
|
32
|
+
|
33
|
+
key_buffer = FFI::Buffer.new(1024)
|
34
|
+
value_buffer = FFI::Buffer.new(8*1024)
|
35
|
+
|
36
|
+
key_pointer = FFI::MemoryPointer.new(key_buffer)
|
37
|
+
value_pointer = FFI::MemoryPointer.new(value_buffer)
|
38
|
+
|
39
|
+
gmsec_ConfigGetFirst(self, key_pointer, value_pointer, status)
|
40
|
+
|
41
|
+
key = key_pointer.read_pointer.read_string_to_null unless status.is_error?
|
42
|
+
value = value_pointer.read_pointer.read_string_to_null unless status.is_error?
|
43
|
+
|
44
|
+
while status.code != GMSEC_CONFIG_END_REACHED && status.code == GMSEC_STATUS_NO_ERROR
|
45
|
+
y << [key, value]
|
46
|
+
gmsec_ConfigGetNext(self, key_pointer, value_pointer, status)
|
47
|
+
|
48
|
+
key = key_pointer.read_pointer.read_string_to_null unless status.is_error?
|
49
|
+
value = value_pointer.read_pointer.read_string_to_null unless status.is_error?
|
50
|
+
end
|
51
|
+
|
52
|
+
if status.code != GMSEC_CONFIG_END_REACHED
|
53
|
+
raise RuntimeError.new("Error reading config fields : #{status}")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def to_xml
|
59
|
+
with_string_pointer do |pointer|
|
60
|
+
gmsec_ConfigToXML(self, pointer, status)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
protected
|
65
|
+
|
66
|
+
def add_value(key, value)
|
67
|
+
gmsec_ConfigAddValue(self, key.to_s, value.to_s, status)
|
68
|
+
get_value(key)
|
69
|
+
end
|
70
|
+
|
71
|
+
def get_value(key)
|
72
|
+
with_string_pointer do |pointer|
|
73
|
+
gmsec_ConfigGetValue(self, key.to_s, pointer, status)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
attach_function :gmsec_ConfigAddValue, [self, :string, :string, GMSEC::Status], :void
|
78
|
+
attach_function :gmsec_ConfigClear, [self, GMSEC::Status], :void
|
79
|
+
attach_function :gmsec_ConfigClearValue, [self, :string, GMSEC::Status], :void
|
80
|
+
attach_function :gmsec_ConfigFromXML, [self, :string, GMSEC::Status], :void
|
81
|
+
attach_function :gmsec_ConfigGetFirst, [self, :pointer, :pointer, GMSEC::Status], :void
|
82
|
+
attach_function :gmsec_ConfigGetNext, [self, :pointer, :pointer, GMSEC::Status], :void
|
83
|
+
attach_function :gmsec_ConfigGetValue, [self, :string, :pointer, GMSEC::Status], :void
|
84
|
+
attach_function :gmsec_ConfigToXML, [self, :pointer, GMSEC::Status], :void
|
85
|
+
attach_function :gmsec_CreateConfig, [:pointer, GMSEC::Status], :void
|
86
|
+
attach_function :gmsec_CreateConfigParams, [:pointer, :int, :pointer, GMSEC::Status], :void
|
87
|
+
attach_function :gmsec_DestroyConfig, [:pointer, GMSEC::Status], :void
|
88
|
+
|
89
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'pry'
|
2
|
+
class GMSEC::ConfigFile
|
3
|
+
extend GMSEC::API
|
4
|
+
|
5
|
+
has :status
|
6
|
+
|
7
|
+
bind :GMSEC_CONFIGFILE_OBJECT
|
8
|
+
|
9
|
+
def initialize(filename)
|
10
|
+
case
|
11
|
+
when filename.nil?
|
12
|
+
raise RuntimeError.new("Unable to create ConfigFile instance: filename not provided")
|
13
|
+
when !File.exist?(filename.to_s)
|
14
|
+
raise RuntimeError.new("Unable to create ConfigFile instance: '#{filename}' does not exist")
|
15
|
+
end
|
16
|
+
|
17
|
+
initialize_native_object do |pointer|
|
18
|
+
gmsec_CreateConfigFile(pointer, filename, status)
|
19
|
+
end
|
20
|
+
|
21
|
+
gmsec_LoadConfigFile(self, status)
|
22
|
+
|
23
|
+
if status.is_error?
|
24
|
+
raise RuntimeError.new("Error reading config file: #{status}")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_xml
|
29
|
+
with_string_pointer do |pointer|
|
30
|
+
gmsec_ToXMLConfigFile(self, pointer, status)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def from_xml(str)
|
35
|
+
gmsec_FromXMLConfigFile(self, str, status)
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_config(config_name)
|
39
|
+
GMSEC::Config.new.tap do |config|
|
40
|
+
gmsec_LookupConfigFileConfig(self, config_name, config, status)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_message(message_name, message: GMSEC::Message.new)
|
45
|
+
message.tap do |message|
|
46
|
+
gmsec_LookupConfigFileMessage(self, message_name, message, status)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def get_subscription(subscription_name)
|
51
|
+
with_string_pointer do |pointer|
|
52
|
+
gmsec_LookupConfigFileSubscription(self, subscription_name, pointer, status)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
attach_function :gmsec_CreateConfigFile, [:pointer, :string, GMSEC::Status], :void
|
57
|
+
attach_function :gmsec_DestroyConfigFile, [:pointer, GMSEC::Status], :void
|
58
|
+
attach_function :gmsec_LoadConfigFile, [self, GMSEC::Status], :void
|
59
|
+
attach_function :gmsec_FromXMLConfigFile, [self, :string, GMSEC::Status], :void
|
60
|
+
attach_function :gmsec_ToXMLConfigFile, [self, :pointer, GMSEC::Status], :void
|
61
|
+
attach_function :gmsec_LookupConfigFileConfig, [self, :string, GMSEC::Config, GMSEC::Status], :void
|
62
|
+
attach_function :gmsec_LookupConfigFileMessage, [self, :string, GMSEC::Message, GMSEC::Status], :void
|
63
|
+
attach_function :gmsec_LookupConfigFileSubscription, [self, :string, :pointer, GMSEC::Status], :void
|
64
|
+
end
|
@@ -0,0 +1,208 @@
|
|
1
|
+
class GMSEC::Connection
|
2
|
+
extend GMSEC::API
|
3
|
+
|
4
|
+
bind :GMSEC_CONNECTION_OBJECT
|
5
|
+
|
6
|
+
has :config, :status
|
7
|
+
|
8
|
+
GMSEC_MESSAGE_TYPE = {
|
9
|
+
publish: GMSEC_MSG_PUBLISH,
|
10
|
+
reply: GMSEC_MSG_REPLY,
|
11
|
+
request: GMSEC_MSG_REQUEST,
|
12
|
+
unset: GMSEC_MSG_UNSET }
|
13
|
+
|
14
|
+
def initialize(config=nil, **config_options)
|
15
|
+
if config || !config_options.nil?
|
16
|
+
self.config = config_options.inject(config || GMSEC::Config.new) do |c, (k,v)|
|
17
|
+
c[k] = v
|
18
|
+
c
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def connect
|
24
|
+
# We initialize the connection assuming that a config is provided before connecting.
|
25
|
+
initialize_native_object do |pointer|
|
26
|
+
gmsec_CreateConnectionForConfig(config, pointer, status)
|
27
|
+
end
|
28
|
+
|
29
|
+
gmsec_Connect(self, status)
|
30
|
+
|
31
|
+
if status.is_error?
|
32
|
+
raise RuntimeError.new("Unable to connect: #{status}")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def connected?
|
37
|
+
gmsec_IsConnected(self, status) == self.class.enum_type(:GMSEC_BOOL)[:GMSEC_TRUE]
|
38
|
+
end
|
39
|
+
|
40
|
+
def disconnect
|
41
|
+
gmsec_Disconnect(self, status)
|
42
|
+
|
43
|
+
if status.is_error?
|
44
|
+
raise RuntimeError.new("Unable to disconnect: #{status}")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def new_message(subject=nil, message_type: :publish, default: true)
|
49
|
+
message_type = GMSEC_MESSAGE_TYPE[message_type].tap do |type|
|
50
|
+
if type.nil?
|
51
|
+
raise RuntimeError.new("Message type '#{message_type}' not supported.")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
pointer = FFI::MemoryPointer.new(GMSEC::Message.native_type)
|
56
|
+
|
57
|
+
case default
|
58
|
+
when true
|
59
|
+
gmsec_CreateMessageDflt(self, pointer, status)
|
60
|
+
when false
|
61
|
+
gmsec_CreateMessage(self, subject, message_type, pointer, status)
|
62
|
+
end
|
63
|
+
|
64
|
+
GMSEC::Message.new(native_object: pointer.read_pointer).tap do |message|
|
65
|
+
if subject
|
66
|
+
message.subject = subject
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def publish(payload=nil, subject: nil)
|
72
|
+
message = case payload
|
73
|
+
when Hash
|
74
|
+
new_message(subject).tap do |message|
|
75
|
+
message << payload
|
76
|
+
end
|
77
|
+
when GMSEC::Message
|
78
|
+
payload
|
79
|
+
else
|
80
|
+
raise RuntimeError.new("Unable to publish payload of type #{payload.class}")
|
81
|
+
end
|
82
|
+
|
83
|
+
gmsec_Publish(self, message, status)
|
84
|
+
|
85
|
+
if status.is_error?
|
86
|
+
raise RuntimeError.new("Unable to publish message: #{status}")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def subscribe(subject, &block)
|
91
|
+
if block_given?
|
92
|
+
callback = FFI::Function.new(:void, [find_type(:GMSEC_CONNECTION_OBJECT), find_type(:GMSEC_MESSAGE_OBJECT)]) do |native_connection, native_message|
|
93
|
+
connection = GMSEC::Connection.new(native_object: native_connection)
|
94
|
+
message = GMSEC::Message.new(native_object: native_message)
|
95
|
+
|
96
|
+
case block.arity
|
97
|
+
when 1
|
98
|
+
block.call(message)
|
99
|
+
when 2
|
100
|
+
block.call(message, connection)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
gmsec_SubscribeWCallback(self, subject, callback, status)
|
105
|
+
else
|
106
|
+
gmsec_Subscribe(self, subject, status)
|
107
|
+
end
|
108
|
+
|
109
|
+
if status.is_error?
|
110
|
+
raise RuntimeError.new("Unable to subscribe: #{status}")
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def messages(timeout: 1000, dispatch: true)
|
115
|
+
Enumerator.new do |y|
|
116
|
+
pointer = FFI::MemoryPointer.new(GMSEC::Message.native_type)
|
117
|
+
gmsec_GetNextMsg(self, pointer, timeout, status)
|
118
|
+
|
119
|
+
while status.code != GMSEC_TIMEOUT_OCCURRED && status.code == 0
|
120
|
+
message = GMSEC::Message.new(native_object: pointer.read_pointer)
|
121
|
+
|
122
|
+
if dispatch
|
123
|
+
gmsec_DispatchMsg(self, message, status)
|
124
|
+
end
|
125
|
+
|
126
|
+
y << message
|
127
|
+
|
128
|
+
gmsec_GetNextMsg(self, pointer, timeout, status)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def library_version
|
134
|
+
with_string_pointer do |pointer|
|
135
|
+
gmsec_GetLibraryVersion(self, pointer, status)
|
136
|
+
|
137
|
+
if status.is_error?
|
138
|
+
raise RuntimeError.new("Unable to get library version: #{status}")
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def library_root_name
|
144
|
+
with_string_pointer do |pointer|
|
145
|
+
gmsec_GetLibraryRootName(self, pointer, status)
|
146
|
+
|
147
|
+
if status.is_error?
|
148
|
+
raise RuntimeError.new("Unable to get library root name: #{status}")
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def start_auto_dispatch
|
154
|
+
gmsec_StartAutoDispatch(self, status)
|
155
|
+
|
156
|
+
if status.is_error?
|
157
|
+
raise RuntimeError.new("Unable to start auto dispatch: #{status}")
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
def stop_auto_dispatch
|
162
|
+
gmsec_StopAutoDispatch(self, status)
|
163
|
+
|
164
|
+
if status.is_error?
|
165
|
+
raise RuntimeError.new("Unable to stop auto dispatch: #{status}")
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def dispatcher_status
|
170
|
+
GMSEC::Status.new.tap do |status|
|
171
|
+
gmsec_GetLastDispatcherStatus(self, status)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
protected
|
176
|
+
|
177
|
+
attach_function :gmsec_CloneMessage, [self, GMSEC::Message, :pointer, GMSEC::Status], :void
|
178
|
+
attach_function :gmsec_Connect, [self, GMSEC::Status], :void
|
179
|
+
attach_function :gmsec_CreateMessage, [self, :string, :GMSEC_MSG_KIND, :pointer, GMSEC::Status], :void
|
180
|
+
attach_function :gmsec_CreateMessageDflt, [self, :pointer, GMSEC::Status], :void
|
181
|
+
attach_function :gmsec_CreateMessageWCFG, [self, :string, :GMSEC_MSG_KIND, :pointer, GMSEC::Config, GMSEC::Status], :void
|
182
|
+
attach_function :gmsec_DestroyMessage, [self, GMSEC::Message, GMSEC::Status], :void
|
183
|
+
attach_function :gmsec_Disconnect, [self, GMSEC::Status], :void
|
184
|
+
attach_function :gmsec_DispatchMsg, [self, GMSEC::Message, GMSEC::Status], :void
|
185
|
+
attach_function :gmsec_GetLastDispatcherStatus, [self, GMSEC::Status], :void
|
186
|
+
attach_function :gmsec_GetLibraryRootName, [self, :pointer, GMSEC::Status], :void
|
187
|
+
attach_function :gmsec_GetLibraryVersion, [self, :pointer, GMSEC::Status], :void
|
188
|
+
attach_function :gmsec_GetNextMsg, [self, :pointer, :GMSEC_I32, GMSEC::Status], :void
|
189
|
+
attach_function :gmsec_IsConnected, [self, GMSEC::Status], :int
|
190
|
+
attach_function :gmsec_Publish, [self, GMSEC::Message, GMSEC::Status], :void
|
191
|
+
attach_function :gmsec_RegisterErrorCallback, [self, :string, :pointer, GMSEC::Status], :void
|
192
|
+
attach_function :gmsec_Reply, [self, GMSEC::Message, GMSEC::Message, GMSEC::Status], :void
|
193
|
+
attach_function :gmsec_Request, [self, GMSEC::Message, :GMSEC_I32, :pointer, GMSEC::Status], :void
|
194
|
+
attach_function :gmsec_RequestWCallback, [self, GMSEC::Message, :GMSEC_I32, :pointer, GMSEC::Status], :void
|
195
|
+
attach_function :gmsec_RequestWReplyCallback, [self, GMSEC::Message, :GMSEC_I32, :pointer, :pointer, GMSEC::Status], :void
|
196
|
+
attach_function :gmsec_StartAutoDispatch, [self, GMSEC::Status], :void
|
197
|
+
attach_function :gmsec_StopAutoDispatch, [self, GMSEC::Status], :void
|
198
|
+
attach_function :gmsec_Subscribe, [self, :string, GMSEC::Status], :void
|
199
|
+
attach_function :gmsec_SubscribeWCallback, [self, :string, :pointer, GMSEC::Status], :void
|
200
|
+
attach_function :gmsec_UnSubscribe, [self, :string, GMSEC::Status], :void
|
201
|
+
attach_function :gmsec_UnSubscribeWCallback, [self, :string, :pointer, GMSEC::Status], :void
|
202
|
+
attach_function :gmsec_GetLastDispatcherStatus, [self, GMSEC::Status], :void
|
203
|
+
|
204
|
+
# From ConnectionFactory
|
205
|
+
attach_function :gmsec_CreateConnection, [:GMSEC_CONNECTION_TYPE, GMSEC::Config, :pointer, GMSEC::Status], :void
|
206
|
+
attach_function :gmsec_CreateConnectionForType, [:GMSEC_CONNECTION_TYPE, GMSEC::Config, :pointer, GMSEC::Status], :void
|
207
|
+
attach_function :gmsec_CreateConnectionForConfig, [GMSEC::Config, :pointer, GMSEC::Status], :void
|
208
|
+
end
|
@@ -0,0 +1,189 @@
|
|
1
|
+
module GMSEC::Definitions
|
2
|
+
|
3
|
+
GMSEC_AUTODISPATCH_EXCLUSIVE = 37
|
4
|
+
GMSEC_AUTODISPATCH_FAILURE = 2
|
5
|
+
GMSEC_BAD_MESSAGE_FORMAT = 33
|
6
|
+
GMSEC_CONFIG_END_REACHED = 6
|
7
|
+
GMSEC_CONNECTION_DISPATCHER_ERROR = "CONNECTION_DISPATCHER_ERROR"
|
8
|
+
GMSEC_CONNECTION_ICSSWB = 1
|
9
|
+
GMSEC_CONNECTION_RENDEZVOUS = 2
|
10
|
+
GMSEC_CONNECTION_REQUEST_TIMEOUT = "CONNECTION_REQUEST_TIMEOUT"
|
11
|
+
GMSEC_CONNECTION_SMARTSOCKETS = 3
|
12
|
+
GMSEC_CUSTOM_ERROR = 36
|
13
|
+
GMSEC_ENCODING_ERROR = 26
|
14
|
+
GMSEC_FEATURE_NOT_SUPPORTED = 4
|
15
|
+
GMSEC_FIELDS_END_REACHED = 9
|
16
|
+
GMSEC_FIELD_TYPE_MISMATCH = 10
|
17
|
+
GMSEC_INITIALIZATION_ERROR = 29
|
18
|
+
GMSEC_INVALID_CALLBACK = 12
|
19
|
+
GMSEC_INVALID_CONFIG = 25
|
20
|
+
GMSEC_INVALID_CONFIG_NAME = 17
|
21
|
+
GMSEC_INVALID_CONFIG_VALUE = 5
|
22
|
+
GMSEC_INVALID_CONNECTION = 3
|
23
|
+
GMSEC_INVALID_CONNECTION_TYPE = 1
|
24
|
+
GMSEC_INVALID_FIELD = 23
|
25
|
+
GMSEC_INVALID_FIELD_NAME = 15
|
26
|
+
GMSEC_INVALID_FIELD_VALUE = 16
|
27
|
+
GMSEC_INVALID_MESSAGE = 7
|
28
|
+
GMSEC_INVALID_NEXT = 28
|
29
|
+
GMSEC_INVALID_SIGNATURE = 34
|
30
|
+
GMSEC_INVALID_SUBJECT_NAME = 18
|
31
|
+
GMSEC_LIBRARY_LOAD_FAILURE = 0
|
32
|
+
GMSEC_MSGCONVERT_FAILURE = 14
|
33
|
+
GMSEC_MSG_PUBLISH = 1
|
34
|
+
GMSEC_MSG_REPLY = 3
|
35
|
+
GMSEC_MSG_REQUEST = 2
|
36
|
+
GMSEC_MSG_UNSET = 0
|
37
|
+
GMSEC_NO_MESSAGE_AVAILABLE = 19
|
38
|
+
GMSEC_NO_WAIT = 0
|
39
|
+
GMSEC_OTHER_ERROR = 50
|
40
|
+
GMSEC_OUT_OF_MEMORY = 27
|
41
|
+
GMSEC_PUBLISH_NOT_AUTHORIZED = 31
|
42
|
+
GMSEC_REQDISPATCH_FAILURE = 13
|
43
|
+
GMSEC_STATUS_CALLBACKLKP_ERROR = 8
|
44
|
+
GMSEC_STATUS_CALLBACK_ERROR = 7
|
45
|
+
GMSEC_STATUS_CONFIGFILE_ERROR = 9
|
46
|
+
GMSEC_STATUS_CONFIG_ERROR = 3
|
47
|
+
GMSEC_STATUS_CONNECTION_ERROR = 2
|
48
|
+
GMSEC_STATUS_CUSTOM_ERROR = 12
|
49
|
+
GMSEC_STATUS_FACTORY_ERROR = 1
|
50
|
+
GMSEC_STATUS_FIELD_ERROR = 6
|
51
|
+
GMSEC_STATUS_ITERATOR_ERROR = 10
|
52
|
+
GMSEC_STATUS_LIBRARY_ERROR = 4
|
53
|
+
GMSEC_STATUS_MESSAGE_ERROR = 5
|
54
|
+
GMSEC_STATUS_NO_ERROR = 0
|
55
|
+
GMSEC_STATUS_OTHER_ERROR = 20
|
56
|
+
GMSEC_STATUS_POLICY_ERROR = 11
|
57
|
+
GMSEC_SUBSCRIBE_NOT_AUTHORIZED = 32
|
58
|
+
GMSEC_TIMEOUT_OCCURRED = 20
|
59
|
+
GMSEC_TRACKING_FAILURE = 21
|
60
|
+
GMSEC_TYPE_BLOB = 10
|
61
|
+
GMSEC_TYPE_BOOL = 2
|
62
|
+
GMSEC_TYPE_CHAR = 1
|
63
|
+
GMSEC_TYPE_COMPOUND = 24
|
64
|
+
GMSEC_TYPE_F32 = 7
|
65
|
+
GMSEC_TYPE_F64 = 8
|
66
|
+
GMSEC_TYPE_I16 = 3
|
67
|
+
GMSEC_TYPE_I32 = 5
|
68
|
+
GMSEC_TYPE_I64 = 22
|
69
|
+
GMSEC_TYPE_I8 = 20
|
70
|
+
GMSEC_TYPE_STR = 9
|
71
|
+
GMSEC_TYPE_U16 = 4
|
72
|
+
GMSEC_TYPE_U32 = 6
|
73
|
+
GMSEC_TYPE_U64 = 23
|
74
|
+
GMSEC_TYPE_U8 = 21
|
75
|
+
GMSEC_TYPE_UNSET = 0
|
76
|
+
GMSEC_UNINITIALIZED_OBJECT = 35
|
77
|
+
GMSEC_UNKNOWN_FIELD_TYPE = 11
|
78
|
+
GMSEC_UNKNOWN_MSG_TYPE = 8
|
79
|
+
GMSEC_UNUSED_CONFIG_ITEM = 22
|
80
|
+
GMSEC_USER_ACCESS_INVALID = 30
|
81
|
+
GMSEC_USING_LONG = 1
|
82
|
+
GMSEC_USING_LONG_LONG = 1
|
83
|
+
GMSEC_USING_SCHAR = 1
|
84
|
+
GMSEC_USING_SHORT = 1
|
85
|
+
GMSEC_USING_UCHAR = 1
|
86
|
+
GMSEC_WAIT_FOREVER = -1
|
87
|
+
GMSEC_XML_PARSE_ERROR = 24
|
88
|
+
MESSAGE_TRACKINGFIELDS_OFF = :GMSEC_FALSE
|
89
|
+
MESSAGE_TRACKINGFIELDS_ON = :GMSEC_TRUE
|
90
|
+
MESSAGE_TRACKINGFIELDS_UNSET = -1
|
91
|
+
NULL = 0
|
92
|
+
REPLY_SUBJECT_FIELD = "GMSEC_REPLY_SUBJECT"
|
93
|
+
|
94
|
+
GMSEC_STATUS_MIDDLEWARE_ERROR = GMSEC_STATUS_LIBRARY_ERROR
|
95
|
+
GMSEC_TYPE_BIN = GMSEC_TYPE_BLOB
|
96
|
+
GMSEC_TYPE_DOUBLE = GMSEC_TYPE_F64
|
97
|
+
GMSEC_TYPE_FLOAT = GMSEC_TYPE_F32
|
98
|
+
GMSEC_TYPE_LONG = GMSEC_TYPE_I32
|
99
|
+
GMSEC_TYPE_SHORT = GMSEC_TYPE_I16
|
100
|
+
GMSEC_TYPE_STRING = GMSEC_TYPE_STR
|
101
|
+
GMSEC_TYPE_ULONG = GMSEC_TYPE_U32
|
102
|
+
GMSEC_TYPE_USHORT = GMSEC_TYPE_U16
|
103
|
+
|
104
|
+
# Will specify layout in `included`
|
105
|
+
class GMSEC_LOG_ENTRY < FFI::Struct; end
|
106
|
+
class GMSEC_CONFIGFILED_STRUCT < FFI::Struct; end
|
107
|
+
class GMSEC_CONFIG_STRUCT < FFI::Struct; end
|
108
|
+
class GMSEC_CONNECTION_STRUCT < FFI::Struct; end
|
109
|
+
class GMSEC_FIELD_STRUCT < FFI::Struct; end
|
110
|
+
class GMSEC_MESSAGE_STRUCT < FFI::Struct; end
|
111
|
+
class GMSEC_STATUS_STRUCT < FFI::Struct; end
|
112
|
+
|
113
|
+
def self.included(base)
|
114
|
+
base.instance_eval do
|
115
|
+
typedef :char, :GMSEC_CHAR
|
116
|
+
typedef :char, :GMSEC_I8
|
117
|
+
typedef :double, :GMSEC_F64
|
118
|
+
typedef :float, :GMSEC_F32
|
119
|
+
typedef :long, :GMSEC_I32
|
120
|
+
typedef :long_long, :GMSEC_I64
|
121
|
+
typedef :pointer, :GMSEC_BIN
|
122
|
+
typedef :pointer, :GMSEC_BLOB
|
123
|
+
typedef :pointer, :GMSEC_CONFIGFILE_OBJECT
|
124
|
+
typedef :pointer, :GMSEC_CONFIGFILE_HANDLE
|
125
|
+
typedef :pointer, :GMSEC_CONFIG_HANDLE
|
126
|
+
typedef :pointer, :GMSEC_CONFIG_OBJECT
|
127
|
+
typedef :pointer, :GMSEC_CONNECTION_HANDLE
|
128
|
+
typedef :pointer, :GMSEC_CONNECTION_OBJECT
|
129
|
+
typedef :pointer, :GMSEC_FIELD_HANDLE
|
130
|
+
typedef :pointer, :GMSEC_FIELD_OBJECT
|
131
|
+
typedef :pointer, :GMSEC_MESSAGE_HANDLE
|
132
|
+
typedef :pointer, :GMSEC_MESSAGE_OBJECT
|
133
|
+
typedef :pointer, :GMSEC_STATUS_HANDLE
|
134
|
+
typedef :pointer, :GMSEC_STATUS_OBJECT
|
135
|
+
typedef :pointer, :GMSEC_STR
|
136
|
+
typedef :pointer, :GMSEC_STRING
|
137
|
+
typedef :short, :GMSEC_I16
|
138
|
+
typedef :uchar, :GMSEC_U8
|
139
|
+
typedef :ulong, :GMSEC_U32
|
140
|
+
typedef :ulong_long, :GMSEC_U64
|
141
|
+
typedef :ushort, :GMSEC_CONNECTION_TYPE
|
142
|
+
typedef :ushort, :GMSEC_STATUS_CLASS
|
143
|
+
typedef :ushort, :GMSEC_TYPE
|
144
|
+
typedef :ushort, :GMSEC_U16
|
145
|
+
|
146
|
+
typedef :GMSEC_F32, :GMSEC_FLOAT
|
147
|
+
typedef :GMSEC_F64, :GMSEC_DOUBLE
|
148
|
+
typedef :GMSEC_I16, :GMSEC_SHORT
|
149
|
+
typedef :GMSEC_I32, :GMSEC_LONG
|
150
|
+
typedef :GMSEC_I64, :GMSEC_LONGLONG
|
151
|
+
typedef :GMSEC_U16, :GMSEC_MSG_KIND
|
152
|
+
typedef :GMSEC_U16, :GMSEC_USHORT
|
153
|
+
typedef :GMSEC_U32, :GMSEC_ULONG
|
154
|
+
typedef :GMSEC_U64, :GMSEC_ULONGLONG
|
155
|
+
|
156
|
+
enum :GMSEC_BOOL, [
|
157
|
+
:GMSEC_FALSE,
|
158
|
+
:GMSEC_TRUE
|
159
|
+
]
|
160
|
+
|
161
|
+
enum :LOG_LEVEL, [
|
162
|
+
:logNONE,
|
163
|
+
:logERROR,
|
164
|
+
:logSECURE,
|
165
|
+
:logWARNING,
|
166
|
+
:logINFO,
|
167
|
+
:logVERBOSE,
|
168
|
+
:logDEBUG,
|
169
|
+
:logNLEVEL
|
170
|
+
]
|
171
|
+
|
172
|
+
callback :GMSEC_CALLBASE, [:GMSEC_CONNECTION_HANDLE, :GMSEC_MESSAGE_HANDLE], :void
|
173
|
+
callback :GMSEC_C_CALLBACK, [:GMSEC_CONNECTION_OBJECT, :GMSEC_MESSAGE_OBJECT], :void
|
174
|
+
callback :GMSEC_ERROR_CALLBACK, [:GMSEC_CONNECTION_HANDLE, :GMSEC_MESSAGE_HANDLE, :GMSEC_STATUS_HANDLE, :string], :void
|
175
|
+
callback :GMSEC_ERROR_CALLBACK, [:GMSEC_CONNECTION_HANDLE, :GMSEC_MESSAGE_HANDLE, :GMSEC_STATUS_HANDLE, :string], :void
|
176
|
+
callback :GMSEC_C_ERROR_CALLBACK, [:GMSEC_CONNECTION_OBJECT, :GMSEC_MESSAGE_OBJECT, :GMSEC_STATUS_OBJECT, :string], :void
|
177
|
+
callback :GMSEC_REPLY_CALLBACK, [:GMSEC_CONNECTION_HANDLE, :GMSEC_MESSAGE_HANDLE, :GMSEC_MESSAGE_HANDLE], :void
|
178
|
+
callback :GMSEC_C_REPLY_CALLBACK, [:GMSEC_CONNECTION_OBJECT, :GMSEC_MESSAGE_OBJECT, :GMSEC_MESSAGE_OBJECT], :void
|
179
|
+
callback :GMSEC_LOGGER_HANDLER, [:pointer], :void
|
180
|
+
end
|
181
|
+
|
182
|
+
base::GMSEC_LOG_ENTRY.layout(
|
183
|
+
file: :string,
|
184
|
+
line: :int,
|
185
|
+
level: base.find_type(:LOG_LEVEL),
|
186
|
+
time: :double,
|
187
|
+
message: :string)
|
188
|
+
end
|
189
|
+
end
|