Download Shareware and Freeware Software for Windows, Linux, Macintosh, PDA

line Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

Serving Software Downloads in 976 Categories, Downloaded 31.071.999 Times

Class::StrongSingleton 0.02

  Date Added: February 15, 2010  |  Visits: 641

Class::StrongSingleton

Report Broken Link
Printer Friendly Version


Product Homepage
Download (73 downloads)

Class::StrongSingleton is a stronger and more secure Singleton base class. SYNOPSIS package My::Singleton::Class; use base qw(Class::StrongSingleton); sub new { my ($class, %my_params) = @_; # create our object instance my $instance = { %my_params }; bless($instance, $class); # and initialize it as a singleton $instance->_init_StrongSingleton(); return $instance; } 1; # later in your code ... # create the first instance of our class my $instance = My::Singleton::Class->new(param => "value"); # try to create a new one again, and # you end up with the same instance, not # a new one my $instance2 = My::Singleton::Class->new(param => "other value"); # calling instance returns the singleton # instance expected my $instance3 = My::Singleton::Class->instance(); # although rarely needed, if you have to # you can destroy the singleton # either through the instance $instance->DESTROY(); # or through the class My::Singleton::Class->DESTROY(); # of course, this is assuming you # did not override DESTORY yourself # Also calling instance before calling new # will returns a new singleton instance my $instance = My::Singleton::Class->instance(); This module is an alternative to Class::Singleton and Class::WeakSingleton, and provides a more secure Singleton class in that it takes steps to prevent the possibility of accidental creation of multiple instances and/or the overwriting of existsing Singleton instances. For a detailed comparison please see the "SEE ALSO" section. Here is a description of how it all works. First, the user creates the first Singleton instance of the class in the normal way. my $obj = My::Singleton::Class->new("variable", "parameter"); This instance is then stored inside a lexically scoped variable within the Class::StrongSingleton package. This prevents the variable from being accessed by anything but methods from the Class::StrongSingleton package. At this point as well, the new method to the class is overridden so that it will always return the Singleton instance. This prevents any accidental overwriting of the Singleton instance. This means that any of the follow lines of code all produce the same instance: my $instance = $obj->instance(); my $instance = My::Singleton::Class->instance(); my $instance = $obj->new(); my $instance = My::Singleton::Class->new(); Personally, I see this an an improvement over the usual Gang of Four style Singletons which discourages the use of the new method entirely. Through this method, a user can be able to use the Singleton class in a normal way, not having to know its actually a Singleton. This can be handy if your design changes and you no longer need the class as a Singleton..

Requirements: No special requirements
Platforms: Linux
Keyword: Base Class Classstrongsingleton Instance Libraries New Programming Secure Singleton Strongsingleton
Users rating: 0/10

License: Freeware Size: 6.14 KB
CLASS::STRONGSINGLETON RELATED
Libraries  -  XML::Schema::Type::Simple 0.07
XML::Schema::Type::Simple is a base class for simple XML Schema datatypes. SYNOPSIS package XML::Schema::Type::whatever; use base qw( XML::Schema::Type::Simple ); use vars qw( @FACETS ); @FACETS = ( minLength => 10, maxLength => 30,...
143.36 KB  
Libraries  -  Myco::Entity 1.22
Myco::Entity is a common base class for all Myco entity classes. SYNOPSIS ### Entity class definition package Myco::Foo; use base qw(Myco::Entity); # Start building metadata my $metadata = Myco::Entity::Meta->new ( name => __PACKAGE__,...
102.4 KB  
Libraries  -  Games::Object 0.11
Games::Object is a Perl module to provide a base class for game objects. SYNOPSIS package MyGameObject; use Games::Object; use vars qw(@ISA); @ISA = qw(Games::Object); sub new { # Create object my $proto = shift; my $class =...
84.99 KB  
Libraries  -  MP3::Find::Base 0.06
MP3::Find::Base is a base class for MP3::Find backends. SYNOPSIS package MyFinder; use base MP3::Find::Base; sub search { my $self = shift; my ($query, $dirs, $sort, $options) = @_; # do something to find and sort the mp3s... my...
29.7 KB  
Libraries  -  Class::Cloneable 0.03
Class::Cloneable is a base class for Cloneable objects. SYNOPSIS package MyObject; our @ISA = (Class::Cloneable); # calling clone on an instance of MyObject # will give you full deep-cloning functionality This module provides a flexible...
8.19 KB  
Libraries  -  Games::LMSolve::Base 0.8.1
Games::LMSolve::Base is a base class for puzzle solvers. SYNOPSIS package MyPuzzle::Solver; use Games::LMSolve::Base; @ISA = qw(Games::LMSolve::Base); # Override these methods: sub input_board { ... } sub pack_state { ... } sub...
21.5 KB  
Libraries  -  Algorithm::Dependency 1.102
Algorithm::Dependency is a base class for implementing various dependency trees. SYNOPSIS use Algorithm::Dependency; use Algorithm::Dependency::Source::File; # Load the data from a simple text file my $data_source =...
46.08 KB  
Libraries  -  ASNMTAP::Asnmtap 3.000.011
ASNMTAP::Asnmtap is an object-oriented Base Class to build modules that provides a nice object oriented interface for ASNMTAP. SYNOPSIS use ASNMTAP::Asnmtap; my $objectAsnmtap = ASNMTAP::Asnmtap->new ( _programName => test-asnmtap.pl,...
1.6 MB  
Libraries  -  Bio::OntologyIO::simplehierarchy 1.4
Bio::OntologyIO::simplehierarchy is a base class parser for simple hierarchy-by-indentation type formats. SYNOPSIS use Bio::OntologyIO; # do not use directly -- use via Bio::OntologyIO my $parser = Bio::OntologyIO->new ( -format =>...
4.7 MB  
Libraries  -  AxKit2::Plugin 1.1
AxKit2::Plugin is a base class for all plugins. An AxKit2 plugin allows you to hook into various parts of processing requests and modify the behaviour of that request. This class is the base class for all plugins and this document covers both...
645.12 KB  
NEW DOWNLOADS IN PROGRAMMING, LIBRARIES
Programming  -  FLEX-db Digital Asset Manager 3.0.9
FLEX-db - an enterprise Digital Asset Manager (DAM). It ingests and links metadata with files, creates thumbnails, and processes files using business rules. FLEX-db has a JSP client, Java app server for file input and output and an EJB metadata...
21.57 MB  
Programming  -  Libicom 0.9.0
The libicom library is a character based dynamicly linked library for Linux. It is used to remotely control the Icom IC-R8500 wide band receiver via an RS232 link. All call and return parameters to the control functions are character string based....
20.48 KB  
Programming  -  dotdesktop 0.3
Dotdesktop library provides ability to parse desktop entry file and access the information in a convenient way. Desktop entry file format is defined by freedesktop.org, it is used to describe information about an application such as the name and...
327.68 KB  
Programming  -  Cedalion for Linux 0.2.6
Cedalion is a programming language that allows its users to add new abstractions and define (and use) internal DSLs. Its innovation is in the fact that it uses projectional editing to allow the new abstractions to have no syntactic limitations.
471.04 KB  
Programming  -  libyasl 0.2
Libyasl is a C++ class library to easily realize TCP/UDP/Multicast clientsand servers in IPv4 and IPv6 environments under GNU/Linux systems.
143.36 KB  
Libraries  -  wolfSSL 3.13.0
The wolfSSL embedded SSL/TLS library is a lightweight SSL library written in ANSI standard C and targeted for embedded and RTOS environments - primarily because of its small size, speed, and feature set. It is commonly used in standard operating...
3.88 MB  
Libraries  -  EuGTK 4.8.9
Makes it easy to develop good- looking, fast, cross-platform programs that run on Linux, OS X, and Windows. Euphoria is a very fast interpreted/compiled language with straight-forward syntax. EuGTK allows programming in a clean, object-oriented...
10.68 MB  
Libraries  -  Linux User Group Library Manager 1.0
The LUG Library Manager is a project to help Linux User Groups start their own library. A LUG library is helpful to the community at large because it increases access to information, and gives everyone the opportunity to become more knowledgeable.
5.35 KB  
Libraries  -  Module::MakefilePL::Parse 0.12
Module::MakefilePL::Parse is a Perl module to parse required modules from Makefile.PL. SYNOPSIS use Module::MakefilePL::Parse; open $fh, Makefile.PL; $parser = Module::MakefilePL::Parse->new( join("", ) ); $info = $parser->required;...
8.19 KB  
Libraries  -  sqlpp 0.06
sqlpp Perl package is a SQL preprocessor. sqlpp is a conventional cpp-alike preprocessor taught to understand SQL ( PgSQL, in particular) syntax specificities. In addition to the standard #define/#ifdef/#else/#endif cohort, provides also...
10.24 KB