options.py
Go to the documentation of this file.
00001 # -*- Python -*-
00002 # -*- coding: utf-8 -*-
00003 
00004 '''rtctree
00005 
00006 Copyright (C) 2009-2014
00007     Geoffrey Biggs
00008     RT-Synthesis Research Group
00009     Intelligent Systems Research Institute,
00010     National Institute of Advanced Industrial Science and Technology (AIST),
00011     Japan
00012     All rights reserved.
00013 Licensed under the Eclipse Public License -v 1.0 (EPL)
00014 http://www.opensource.org/licenses/eclipse-1.0.txt
00015 
00016 Singleton containing option values.
00017 
00018 '''
00019 
00020 
00021 import sys
00022 
00023 from rtctree.exceptions import NoSuchOptionError
00024 
00025 
00026 ##############################################################################
00027 ## Options object
00028 
00029 class Options(object):
00030     def __new__(cls, *p, **k):
00031         if not '_the_instance' in cls.__dict__:
00032             cls._the_instance = object.__new__(cls)
00033         return cls._the_instance
00034 
00035     def init_options(self):
00036         self.options = {'max_bindings': 100}
00037 
00038     def set_option(self, option, value):
00039         if not hasattr(self, 'options'):
00040             self.init_options()
00041         self.options[option] = value
00042 
00043     def get_option(self, option):
00044         if not hasattr(self, 'options'):
00045             self.init_options()
00046         if not option in self.options:
00047             raise NoSuchOptionError(option)
00048         return self.options[option]
00049 
00050 
00051 # vim: tw=79
00052 


rtctree
Author(s): Geoffrey Biggs
autogenerated on Wed Aug 26 2015 16:13:08