switching licenses
[lwes-perl.git] / LWES.pm
blobc935a8b53097a3d71585ce9dfe4e51a2f4034583
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 Portions Copyright (c) 2008, Yahoo! Inc. All rights reserved.
154 Portions Copyright (c) 2010, OpenX Inc. All rights reserved.
156 Licensed under the New BSD License (the "License"); you may not use
157 this file except in compliance with the License. Unless required
158 by applicable law or agreed to in writing, software distributed
159 under the License is distributed on an "AS IS" BASIS, WITHOUT
160 WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
161 See the License for the specific language governing permissions and
162 limitations under the License. See accompanying LICENSE file.
164 =cut