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

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

Serving Software Downloads in 956 Categories, Downloaded 50.178.381 Times

Class::StrongSingleton 0.02

  Date Added: February 15, 2010  |  Visits: 843

Class::StrongSingleton

Report Broken Link
Printer Friendly Version


Product Homepage
Download (96 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
USER REVIEWS
More Reviews or Write Review


CLASS::STRONGSINGLETON RELATED
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  
Miscellaneous  -  A class keeps a reference to it's instance 1.1
This script implements a base class, which allows derived classes to track instances in self.__instances__. It uses a WeakValueDictionary to store instance references.
 
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  -  C++ base 1.0
C++ base is a base class suite contains several powerful c++ base classes for basic encapsulation of low level operating system calls and basic library functions. Further packages you may access from this page require the installation of this...
102.4 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  -  Persistent::Base 0.52
Persistent::Base is an Abstract Persistent Base Class. SYNOPSIS ### we are a subclass of ... ### use Persistent::Base; @ISA = qw(Persistent::Base); ABSTRACT This is an abstract class used by the Persistent framework of classes to...
38.91 KB  
Libraries  -  dtRdr::GUI::Wx::Tree::Base 0.0.11
dtRdr::GUI::Wx::Tree::Base is a base class for sidebar trees. SYNOPSIS init $tree->init($frame); select_item Select the tree item for a given $id. $tree->select_item($id) The id is probably the id of whatever your widget associated...
2.8 MB  
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  
NEW DOWNLOADS IN PROGRAMMING, LIBRARIES
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  -  Math::GMPf 0.29
Math::GMPf - perl interface to the GMP library's floating point (mpf) functions.
30.72 KB  
Programming  -  Net::Wire10 1.08
Net::Wire10 is a Pure Perl connector that talks to Sphinx, MySQL and Drizzle servers. Net::Wire10 implements the low-level network protocol, alias the MySQL wire protocol version 10, necessary for talking to one of the aforementioned...
30.72 KB  
Programming  -  logilab-common 0.56.2
a bunch of modules providing low level functionnalities shared among some python projects devel Please note that some of the modules have some extra dependencies. For instance, logilab.common.db will require a db-api 2.0 compliant...
174.08 KB  
Programming  -  OpenSSL for linux 1.0.0a
The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well as a...
3.83 MB  
Libraries  -  wolfSSL 4.0.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