mailr7808 - /branches/multi_processor_merge/multi/processor.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on October 18, 2008 - 17:48:
Author: bugman
Date: Sat Oct 18 17:48:26 2008
New Revision: 7808

URL: http://svn.gna.org/viewcvs/relax?rev=7808&view=rev
Log:
Created a singleton container class called Processor_box for storing the 
Processors.

This can then be used to get access to the Processor.


Modified:
    branches/multi_processor_merge/multi/processor.py

Modified: branches/multi_processor_merge/multi/processor.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/multi/processor.py?rev=7808&r1=7807&r2=7808&view=diff
==============================================================================
--- branches/multi_processor_merge/multi/processor.py (original)
+++ branches/multi_processor_merge/multi/processor.py Sat Oct 18 17:48:26 2008
@@ -827,6 +827,27 @@
         return (stdout_capture, stderr_capture)
 
 
+class Processor_box:
+    """A storage class for the Processor instance and its attributes.
+
+    This singleton contains Processor instances and information about these 
Processors.  Importantly
+    this container gives the calling code access to the Processor.
+    """
+
+    # Class variable for storing the class instance.
+    instance = None
+
+    def __new__(self, *args, **kargs): 
+        """Replacement function for implementing the singleton design 
pattern."""
+
+        # First initialisation.
+        if self.instance is None:
+            self.instance = object.__new__(self, *args, **kargs)
+
+        # Already initialised, so return the instance.
+        return self.instance
+
+
 # TODO currently uni_processor doesn't have a process_result should this be 
integrated
 class Result(object):
     '''A basic result object returned from a slave processor via 
return_object.




Related Messages


Powered by MHonArc, Updated Sat Oct 18 18:00:04 2008