| 1 | # Singleton variables and functions | ||
| 2 | package RWDE::Singleton; | ||
| 3 | |||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | |||
| 7 | use vars qw($VERSION); | ||
| 8 | $VERSION = sprintf "%d", q$Revision: 507 $ =~ /(\d+)/; | ||
| 9 | |||
| 10 | sub new { | ||
| 11 | my ($class, $params) = @_; | ||
| 12 | |||
| 13 | if (caller() ne $class) { | ||
| 14 | my ($package, $filename, $line) = caller(); | ||
| 15 | throw RWDE::DevelException({ info => " ($package) from $filename Line: $line is trying to access the constructor directly. Use get_instance instead." }); | ||
| 16 | } | ||
| 17 | |||
| 18 | my $self = { _data => 'something' }; | ||
| 19 | |||
| 20 | bless($self, $class); | ||
| 21 | |||
| 22 | $self->initialize($params); | ||
| 23 | |||
| 24 | return $self; | ||
| 25 | } | ||
| 26 | |||
| 27 | sub initialize { | ||
| 28 | my ($self, $params) = @_; | ||
| 29 | |||
| 30 | return (); | ||
| 31 | } | ||
| 32 | |||
| 33 | # do nothing. here just to shut up TT when AUTOLOAD is present | ||
| 34 | sub DESTROY { | ||
| 35 | |||
| 36 | } | ||
| 37 | |||
| 38 | 1; |