minor fixups
[lwes-perl.git] / LWES.pm
blob49144bbd6e1a28132ebd3c302b0a4dbbb4216210
1 # This file was automatically generated by SWIG
2 package LWES;
3 require Exporter;
4 require DynaLoader;
5 @ISA = qw(Exporter DynaLoader);
6 package LWESc;
7 bootstrap LWES;
8 package LWES;
9 @EXPORT = qw( );
11 # ---------- BASE METHODS -------------
13 package LWES;
15 sub TIEHASH {
16 my ($classname,$obj) = @_;
17 return bless $obj, $classname;
20 sub CLEAR { }
22 sub FIRSTKEY { }
24 sub NEXTKEY { }
26 sub FETCH {
27 my ($self,$field) = @_;
28 my $member_func = "swig_${field}_get";
29 $self->$member_func();
32 sub STORE {
33 my ($self,$field,$newval) = @_;
34 my $member_func = "swig_${field}_set";
35 $self->$member_func($newval);
38 sub this {
39 my $ptr = shift;
40 return tied(%$ptr);
44 # ------- FUNCTION WRAPPERS --------
46 package LWES;
48 *create_db = *LWESc::create_db;
49 *destroy_db = *LWESc::destroy_db;
50 *create_emitter = *LWESc::create_emitter;
51 *create_emitter_with_ttl = *LWESc::create_emitter_with_ttl;
52 *emit = *LWESc::emit;
53 *emitto = *LWESc::emitto;
54 *destroy_emitter = *LWESc::destroy_emitter;
55 *create_event = *LWESc::create_event;
56 *create_event_with_encoding = *LWESc::create_event_with_encoding;
57 *set_uint16 = *LWESc::set_uint16;
58 *get_uint16 = *LWESc::get_uint16;
59 *set_int16 = *LWESc::set_int16;
60 *get_int16 = *LWESc::get_int16;
61 *set_uint32 = *LWESc::set_uint32;
62 *get_uint32 = *LWESc::get_uint32;
63 *set_int32 = *LWESc::set_int32;
64 *get_int32 = *LWESc::get_int32;
65 *set_uint64 = *LWESc::set_uint64;
66 *get_uint64 = *LWESc::get_uint64;
67 *set_int64 = *LWESc::set_int64;
68 *get_int64 = *LWESc::get_int64;
69 *set_string = *LWESc::set_string;
70 *get_string = *LWESc::get_string;
71 *set_ip_addr = *LWESc::set_ip_addr;
72 *get_ip_addr = *LWESc::get_ip_addr;
73 *set_boolean = *LWESc::set_boolean;
74 *get_boolean = *LWESc::get_boolean;
75 *destroy_event = *LWESc::destroy_event;
76 *current_time_millis = *LWESc::current_time_millis;
78 # ------- VARIABLE STUBS --------
80 package LWES;
84 =head1 NAME
86 LWES - Perl extension for the Light Weight Event System
88 =head1 SYNOPSIS
90 use LWES;
91 use LWES::EventParser;
92 use IO::Socket::Multicast;
94 my $LWES_ADDRESS = "224.1.1.1";
95 my $LWES_PORT = 9000;
97 # load an event schema from a file to validate events
98 my $event_db = LWES::create_db("eventTypes.esf");
100 # create an emitter for sending events
101 my $emitter = LWES::create_emitter($LWES_ADDRESS, 0, $LWES_PORT, 0, 60);
103 # create an event and validate it against the DB
104 my $event = LWES::create_event($event_db, "MyEvent");
106 # or create an unvalidated event
107 my $event2 = LWES::create_event(undef, "MyOtherEvent");
109 # set some fields
110 LWES::set_string($event, "MyField", "MyValue");
111 LWES::set_int32($event2, "MyNumber", 123);
113 # emit the events
114 LWES::emit($emitter, $event);
115 LWES::emit($emitter, $event2);
117 # listen to some events on the network
118 my $socket = IO::Socket::Multicast->new(LocalPort => $LWES_PORT,
119 Reuse => 1);
120 $socket->mcast_add($LWES_ADDRESS);
121 my ($message, $peer);
122 $peer = recv($socket, $message, 65535, 0);
123 my ($port, $peeraddr) = sockaddr_in($peer);
125 # deserialize the event into a perl hash
126 my $event = bytesToEvent($message);
128 # access the various event fields
129 my $data = $event->{'MyField'};
131 # cleanup
132 LWES::destroy_event($event);
133 LWES::destroy_emitter($emitter);
134 LWES::destroy_db($event_db);
136 =head1 DESCRIPTION
138 This is the Perl interface to the Light Weight Event System. The
139 Light Weight Event System is a UDP-based communication toolkit with
140 built-in serialization, formatting, and type-checking.
142 =head1 EXPORT
144 None by default.
146 =head1 AUTHOR
148 Anthony Molinaro, E<lt>molinaro@users.sourceforge.netE<gt>
149 Michael P. Lum, E<lt>mlum@users.sourceforge.netE<gt>
151 =head1 COPYRIGHT AND LICENSE
153 Copyright (C) 2008 Light Weight Event System
154 All rights reserved.
156 This program is free software: you can redistribute it and/or modify
157 it under the terms of the GNU General Public License as published by
158 the Free Software Foundation, either version 2 of the License, or
159 (at your option) any later version.
161 This program is distributed in the hope that it will be useful,
162 but WITHOUT ANY WARRANTY; without even the implied warranty of
163 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
164 GNU General Public License for more details.
166 You should have received a copy of the GNU General Public License
167 along with this program. If not, see <http://www.gnu.org/licenses/>.
169 =cut