File: Message.pm

package info (click to toggle)
libhipi-perl 0.94-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,048 kB
  • sloc: perl: 471,918; ansic: 22; makefile: 10
file content (68 lines) | stat: -rw-r--r-- 1,635 bytes parent folder | download | duplicates (2)
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
#########################################################################################
# Package        HiPi::RF::Message
# Description  : Generic protocol message
# Copyright    : Copyright (c) 2023 Mark Dootson
# License      : This is free software; you can redistribute it and/or modify it under
#                the same terms as the Perl 5 programming language system itself.
#########################################################################################

package HiPi::RF::Message;

#########################################################################################

use strict;
use warnings;
use parent qw( HiPi::Class );

our $VERSION ='0.89';

__PACKAGE__->create_accessors( qw(
    errorbuffer
    databuffer
    is_decoded
    is_encoded
));

sub new {
    my( $class, %params ) = @_;
    $params{errorbuffer}  = [];
    $params{databuffer} //= [];
    my $self = $class->SUPER::new( %params );
    return $self;
}

sub push_error {
    my( $self, $error) = @_;
    if ( $error ) {
       push( @{ $self->errorbuffer }, $error );
    }
    return;
}

sub error {
    my $self = shift;
    return scalar @{ $self->errorbuffer };
}

sub shift_error {
    my $self = shift;
    my $rval = shift @{ $self->errorbuffer };
    return $rval;
}

sub inspect_buffer {
    my $self = shift;
    $self->push_error('Override inspect_buffer method in a derived class');
}

sub decode_buffer {
    my $self = shift;
    $self->push_error('Override decode_buffer method in a derived class');
}

sub encode_buffer {
    my $self = shift;
    $self->push_error('Override encode_buffer method in a derived class');
}

1;