]> git.evergreen-ils.org Git - Evergreen.git/blob - OpenSRF/src/perlmods/OpenSRF/Application/Demo/MathDB.pm
Initial revision
[Evergreen.git] / OpenSRF / src / perlmods / OpenSRF / Application / Demo / MathDB.pm
1 package OpenSRF::Application::Demo::MathDB;
2 use base qw/OpenSRF::Application/;
3 use OpenSRF::Application;
4 use OpenSRF::DomainObject::oilsResponse qw/:status/;
5 use OpenSRF::DomainObject::oilsPrimitive;
6 use OpenSRF::Utils::Logger qw/:level/;
7 use strict;
8 use warnings;
9 sub DESTROY{}
10 our $log = 'OpenSRF::Utils::Logger';
11
12 #sub method_lookup {
13 #
14 #       my( $class, $method_name, $method_proto ) = @_;
15 #
16 #       if( $method_name eq "add" ) {
17 #               return \&add;
18 #       }
19 #
20 #       if( $method_name eq "sub" ) {
21 #               return \⊂
22 #       }
23 #
24 #       if( $method_name eq "mult" ) {
25 #               return \&mult;
26 #       }
27 #
28 #       if( $method_name eq "div" ) {
29 #               return \÷
30 #       }
31 #
32 #       return undef;
33 #
34 #}
35
36 sub add_1 {
37         my $client = shift;
38         my @args = @_;
39         $log->debug("Adding @args", INTERNAL);
40         $log->debug("AppRequest is $client", INTERNAL);
41         my $n1 = shift; my $n2 = shift;
42         $n1 =~ s/\s+//; $n2 =~ s/\s+//;
43         my $a = $n1 + $n2;
44         my $result = new OpenSRF::DomainObject::oilsResult;
45         $result->content( OpenSRF::DomainObject::oilsScalar->new($a) );
46         return $result;
47         $client->respond($result);
48         return 1;
49 }
50 sub sub_1 {
51         my $client = shift;
52         my @args = @_;
53         $log->debug("Subbing @args", INTERNAL);
54         $log->debug("AppRequest is $client", INTERNAL);
55         my $n1 = shift; my $n2 = shift;
56         $n1 =~ s/\s+//; $n2 =~ s/\s+//;
57         my $a = $n1 - $n2;
58         my $result = new OpenSRF::DomainObject::oilsResult;
59         $result->content( OpenSRF::DomainObject::oilsScalar->new($a) );
60         return $result;
61         $client->respond($result);
62         return 1;
63 }
64
65 sub mult_1 {
66         my $client = shift;
67         my @args = @_;
68         $log->debug("Multiplying @args", INTERNAL);
69         $log->debug("AppRequest is $client", INTERNAL);
70         my $n1 = shift; my $n2 = shift;
71         $n1 =~ s/\s+//; $n2 =~ s/\s+//;
72         my $a = $n1 * $n2;
73         my $result = new OpenSRF::DomainObject::oilsResult;
74         $result->content( OpenSRF::DomainObject::oilsScalar->new($a) );
75 #       $client->respond($result);
76         return $result;
77 }
78
79 sub div_1 {
80         my $client = shift;
81         my @args = @_;
82         $log->debug("Dividing @args", INTERNAL);
83         $log->debug("AppRequest is $client", INTERNAL);
84         my $n1 = shift; my $n2 = shift;
85         $n1 =~ s/\s+//; $n2 =~ s/\s+//;
86         my $a = $n1 / $n2;
87         my $result = new OpenSRF::DomainObject::oilsResult;
88         $result->content( OpenSRF::DomainObject::oilsScalar->new($a) );
89         return $result;
90         $client->respond($result);
91         return 1;
92 }
93
94 1;