'''Wrappers for Guppi's plotting plug-ins. Most of this file is autogenerated.
'''

import _guppi
from Guppi import *

class LazyModule:
    '''This class is needed to implement lazy loading of plugins.
    To facilitate the use of a module M, we create a LazyModule with name
    "M". When someone tries to access object M.x, the LazyModule instance
    imports the _real_ module M, gives up its ownership of the name M to 
    the new module M, and then fulfills the original request.

    Note that this only works in the same namespace, so you can't
    import this module and then use LazyModule in another namespace 
    and expect it to work.
        
    name = name of the real module.'''
        
    def __init__(self, name):
	self.name = name
    def __getattr__(self, attr):
        self.initModule()
	exec ('''import %(m)s
_x=%(m)s
global %(m)s
%(m)s = _x''' % {'m' : self.name})
	return getattr(_x, attr)

    def initModule(self):
        '''overload this method to initialize the module'''
        pass


class LazyPluginModule(LazyModule):
    '''A LazyModule which initializes a Guppi plugin and loads its module.'''
    def __init__(self, name, plugin_type, plugin_code):
        LazyModule.__init__(self, name)
        self.plugin_type = plugin_type
        self.plugin_code = plugin_code
        
    def initModule(self):
        _guppi.load_plug_in(self.plugin_type, self.plugin_code)
import _g_python_curve_func


def curve_new_reparameterize_linearly(t0, t1, c):
    """Autogenerated from C function:
       GuppiData guppi_curve_new_reparameterize_linearly(double t0, double t1, GuppiCurve c)"""
    _ret = _g_python_curve_func.guppi_curve_new_reparameterize_linearly(t0, t1, c)
    if type(_ret) is _guppi.GuppiObjectType: _ret = _obj2inst(_ret)
    return _ret
import _g_python_curve_calc

import _g_python_curve_poly


def curve_new_polynomial2(c0, c1, c2):
    """Autogenerated from C function:
       GuppiData guppi_curve_new_polynomial2(double c0, double c1, double c2)"""
    _ret = _g_python_curve_poly.guppi_curve_new_polynomial2(c0, c1, c2)
    if type(_ret) is _guppi.GuppiObjectType: _ret = _obj2inst(_ret)
    return _ret

def curve_new_polynomial3(c0, c1, c2, c3):
    """Autogenerated from C function:
       GuppiData guppi_curve_new_polynomial3(double c0, double c1, double c2, double c3)"""
    _ret = _g_python_curve_poly.guppi_curve_new_polynomial3(c0, c1, c2, c3)
    if type(_ret) is _guppi.GuppiObjectType: _ret = _obj2inst(_ret)
    return _ret
import _g_python_date_series_calc

class GuppiDateIndexed(GuppiData):    
    def __init__(self,  _obj=None):
        if _obj: self._o = _obj; return
        raise ValueError, "Class does not have a constructor."
        

class GuppiDateSeries(GuppiDateIndexed):    
    def __init__(self,  _obj=None):
        if _obj: self._o = _obj; return
        raise ValueError, "Class does not have a constructor."
        
    def new_moving_average(self, days):
        """Autogenerated from C function:
           GuppiData guppi_date_series_new_moving_average(self, int days)"""
        
        _ret = _g_python_date_series_calc.guppi_date_series_new_moving_average(self._o, days)
        if type(_ret) is _guppi.GuppiObjectType: _ret = _obj2inst(_ret)
        return _ret
    

class GuppiPriceSeries(GuppiDateIndexed):    
    def __init__(self,  _obj=None):
        if _obj: self._o = _obj; return
        raise ValueError, "Class does not have a constructor."
        
    def guppi_date_series_new_price_series_open(self, ):
        """Autogenerated from C function:
           GuppiData guppi_price_series_guppi_date_series_new_price_series_open(self, )"""
        
        _ret = _g_python_date_series_calc.guppi_price_series_guppi_date_series_new_price_series_open(self._o, )
        if type(_ret) is _guppi.GuppiObjectType: _ret = _obj2inst(_ret)
        return _ret
    
    
    def guppi_date_series_new_price_series_high(self, ):
        """Autogenerated from C function:
           GuppiData guppi_price_series_guppi_date_series_new_price_series_high(self, )"""
        
        _ret = _g_python_date_series_calc.guppi_price_series_guppi_date_series_new_price_series_high(self._o, )
        if type(_ret) is _guppi.GuppiObjectType: _ret = _obj2inst(_ret)
        return _ret
    
    
    def guppi_date_series_new_price_series_low(self, ):
        """Autogenerated from C function:
           GuppiData guppi_price_series_guppi_date_series_new_price_series_low(self, )"""
        
        _ret = _g_python_date_series_calc.guppi_price_series_guppi_date_series_new_price_series_low(self._o, )
        if type(_ret) is _guppi.GuppiObjectType: _ret = _obj2inst(_ret)
        return _ret
    
    
    def guppi_date_series_new_price_series_close(self, ):
        """Autogenerated from C function:
           GuppiData guppi_price_series_guppi_date_series_new_price_series_close(self, )"""
        
        _ret = _g_python_date_series_calc.guppi_price_series_guppi_date_series_new_price_series_close(self._o, )
        if type(_ret) is _guppi.GuppiObjectType: _ret = _obj2inst(_ret)
        return _ret
    

import _g_python_date_series_core

import _g_python_seq_scalar_func

import _g_python_seq_scalar_calc

import _g_python_seq_scalar_core

_name2cls = {}
_supported = map(lambda x: eval(x), filter(lambda x: x[:5] == 'Guppi', dir()))
_m = None
for _m in _supported:
    _name2cls[_m.__name__] = _m
del _m
_guppi.register_classes(_name2cls)
def _obj2inst(obj):
        objname = _guppi.type_name(obj)
        if _guppi.classes.has_key(objname):
                return _guppi.classes[objname](_obj=obj)
        else: return obj
