Files
Michel Stam 70ced29fc3 Add libraries for generating JSON messages
relates to ripe-atlas-software-probe#15

Changelog: added
2022-09-07 13:00:17 +02:00

43 lines
1.2 KiB
Bash

#!/bin/sh
#
# Support functions for object oriented functionality in shell scripts
# Copyright (c) 2022 RIPE NCC
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
#
# function to call class constructor
# Usage: new <class> <variable> <args>
# <variable> will be a new variable in the global environment.
#
new( )
{
local class="${1}"
shift
eval "${class}_constructor" \"\${@}\"
}
#
# function to call class destructor
# Usage: delete <variable>
# <variable> will be unset in the global environment.
#
delete( )
{
eval "\${${1}} destructor"
unset ${1}
}