How to use replication - 10 common examples

To help you get started, we’ve selected a few replication examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xtreemfs / babudb / replication / share / yidl / src / yidl / target.py View on Github external
def getConstants( self ): return self.__constants
    def isLocal( self ): return self.__local        


class Type(Construct):
    def __repr__( self ):  
        return self.getQualifiedName( "::" )
    
    def getMarshallerTypeName( self ):
        return "".join( ["".join( ( space_part[0].upper(), space_part[1:] ) ) for space_part in self.getName().split( " " )] )        


class BoolType(Type): pass


class BufferType(Type): pass


class Declaration(Construct):
    def __init__( self, scope, type, qname, tag=0, default_value=None ):        
        assert isinstance( type, Type )
        Construct.__init__( self, scope, qname, tag )
        self.__type = type
        self.__default_value = default_value

    def __repr__( self ):
        return repr( self.getType() ) + " " + self.getIdentifier()

    def getDefaultValue( self ): return self.__default_value
    def getIdentifier( self ): return self.getName()    
    def getType( self ): return self.__type
github xtreemfs / babudb / replication / share / yidl / src / yidl / target.py View on Github external
class Type(Construct):
    def __repr__( self ):  
        return self.getQualifiedName( "::" )
    
    def getMarshallerTypeName( self ):
        return "".join( ["".join( ( space_part[0].upper(), space_part[1:] ) ) for space_part in self.getName().split( " " )] )        


class BoolType(Type): pass


class BufferType(Type): pass


class Declaration(Construct):
    def __init__( self, scope, type, qname, tag=0, default_value=None ):        
        assert isinstance( type, Type )
        Construct.__init__( self, scope, qname, tag )
        self.__type = type
        self.__default_value = default_value

    def __repr__( self ):
        return repr( self.getType() ) + " " + self.getIdentifier()

    def getDefaultValue( self ): return self.__default_value
    def getIdentifier( self ): return self.getName()    
    def getType( self ): return self.__type    


class Constant(Declaration):
    def __init__( self, scope, type, qname, value ):
github xtreemfs / babudb / replication / share / yidl / src / yidl / target.py View on Github external
includes.extend( construct.getIncludes() )
        return includes
    
    def getInterfaces( self ): return self.__interfaces
    def getModules( self ): return self.__modules
    def getTypes( self ): return self.__types                   


class NumericType(Type):
    def getMarshallerTypeName( self ):
        name = self.getName()
        if name.endswith( "_t" ): name = name[:-2]
        return "".join( ["".join( ( space_part[0].upper(), space_part[1:] ) ) for space_part in name.split( " " )] )


class Operation(Construct):
    def __init__( self, scope, qname, oneway=False, return_type=None, const=False, tag=0 ):
        if oneway: assert return_type is None
        else: assert return_type is None or isinstance( return_type, Type )        
        assert isinstance( const, bool )
        Construct.__init__( self, scope, qname, tag )
        self.__oneway = oneway
        self.__return_type = return_type
        self.__const = const
        self.__parameters = []     

    def __repr__( self ):
        return self.__class__.__name__ + " " + ( self.isOneway() and "oneway " or "" ) + ( self.getReturnType() is None and "void" or repr( self.getReturnType() ) ) + " " + self.getName() + "( " + ", ".join( [repr( param ) for param in self.getParameters()] ) + " );"
    
    def addParameter( self, parameter, *args, **kwds ): return self._addConstruct( parameter, "OperationParameter", OperationParameter, self.__parameters, *args, **kwds )
    def getInboundParameters( self ): return [param for param in self.getParameters() if param.isInbound()]
    def getOutboundParameters( self, include_return_value=None ): return [param for param in self.getParameters() if param.isOutbound()]
github xtreemfs / babudb / replication / share / yidl / src / yidl / target.py View on Github external
class Scope(Construct):
    def __init__( self, scope, qname, local=False, tag=0 ):            
        Construct.__init__( self, scope, qname, tag )
        self.__local = local
        self.__constants = []

    def __repr__( self ):
        return rpad( "\n".join( [repr( constant ) for constant in self.getConstants()] ), "\n\n" )
                    
    def addConstant( self, constant, *args, **kwds ): return self._addConstruct( constant, "Constant", Constant, self.__constants, *args, **kwds )                
    def getConstants( self ): return self.__constants
    def isLocal( self ): return self.__local        


class Type(Construct):
    def __repr__( self ):  
        return self.getQualifiedName( "::" )
    
    def getMarshallerTypeName( self ):
        return "".join( ["".join( ( space_part[0].upper(), space_part[1:] ) ) for space_part in self.getName().split( " " )] )        


class BoolType(Type): pass


class BufferType(Type): pass


class Declaration(Construct):
    def __init__( self, scope, type, qname, tag=0, default_value=None ):        
        assert isinstance( type, Type )
github xtreemfs / babudb / replication / share / yidl / src / yidl / py_target.py View on Github external
if name.endswith( "_t" ): name = name[:-2]
        return "".join( ["".join( ( space_part[0].upper(), space_part[1:] ) ) for space_part in name.split( " " )] )


class PyOperation(Operation):
    def __repr__( self ):
        name = self.getName()        
        param_decls = ["self"]
        for param in self.getParameters():
            assert not param.isOutbound()
            param_decls.append( param.getIdentifier() )            
        param_decls = pad( " ", ", ".join( param_decls ), " " )
        return "def %(name)s(%(param_decls)s): raise NotImplementedError" % locals()

    
class PyPointerType(PointerType, PyPrimitiveType):
    def getBoxedTypeName( self ): return "buffer"
    def getCast( self, var_name ): return var_name
    def getDefaultValue( self ): return "\"\""
       
    
class PySequenceType(SequenceType, PyCompoundType):
    def __repr__( self ):
        name = self.getName()
        value_new = self.getValueType().getBoxedTypeName()
        value_cast = self.getValueType().getCast( "value" )
        value_write = self.getValueType().getMarshalCall( "( *this )[i]", "value" )
        value_read = self.getValueType().getUnmarshalCall( "( *this )[i]", "self[i]" )
        return """
class %(name)s(list):
    def __init__( self, init_list=[] ):
        list.__init__( self )
github xtreemfs / babudb / replication / share / yidl / src / yidl / py_target.py View on Github external
return """\
class %(name)s(object):
%(operations)s
""" % locals()
   

class PyMapType(MapType, PyCompoundType):
    def __repr__( self ):
        name = self.getName()
        return """
class %(name)s(dict): pass
""" % locals()
        
    
class PyNumericType(NumericType, PyPrimitiveType):    
    def getBoxedTypeName( self ):
        if self.getName() == "float" or self.getName() == "double": return "float"
        elif self.getName().endswith( "int64_t" ): return "long" 
        else: return "int"

    def getCast( self, var_name ):
        if self.getName() == "float" or self.getName() == "double": return "type( %(var_name)s ) == float and %(var_name)s or float( %(var_name)s )" % locals()
        else: return "( type( %(var_name)s ) == int or type( %(var_name)s ) == long ) and %(var_name)s or long( %(var_name)s )" % locals()

    def getDefaultValue( self ): return "0"
    
    def getMarshallerTypeName( self ):
        name = self.getName()
        if name.endswith( "_t" ): name = name[:-2]
        return "".join( ["".join( ( space_part[0].upper(), space_part[1:] ) ) for space_part in name.split( " " )] )
github xtreemfs / babudb / replication / share / yidl / src / yidl / target.py View on Github external
nonlocal_includes_dict = dict( ( include.getFilePath(), include ) for include in includes if not include.isLocal() )
        local_includes_dict_keys = local_includes_dict.keys()
        local_includes_dict_keys.sort()
        nonlocal_includes_dict_keys = nonlocal_includes_dict.keys()
        nonlocal_includes_dict_keys.sort()        
        includes = []
        for includes_dict_key in local_includes_dict_keys:
            includes.append( local_includes_dict[includes_dict_key] )            
        for includes_dict_key in nonlocal_includes_dict_keys:
            includes.append( nonlocal_includes_dict[includes_dict_key] )                        
        return includes
    
    def getModules( self ): return self.__modules


class VariadicType(Type): pass
github xtreemfs / babudb / replication / share / yidl / src / yidl / target.py View on Github external
assert in_ or out_        
        Declaration.__init__( self, scope, type, qname, tag, default_value )
        self.__in = in_
        self.__out = out_
        
    def __repr__( self ):
        inout = []
        if self.isInbound(): inout.append( "in" )
        if self.isOutbound: inout.append( "out" )
        return "".join( inout ) + " " + Declaration.__repr__( self )

    def isInbound( self ): return self.__in
    def isOutbound( self ): return self.__out
        
        
class PointerType(Type):
    def getMarshallerTypeName(): return "Pointer"    


class ReferenceType(PointerType): pass


class SequenceType(Type):
    def __init__( self, scope, qname, tag, value_type ):
        Type.__init__( self, scope, qname, tag )
        self.__value_type = value_type

    def __repr__( self ):
        return self.__class__.__name__ + " " + self.getName() + "<" + repr( self.getValueType() ) + ">;"        

    def getMarshallerTypeName( self ): return "Sequence"
    def getValueType( self ): return self.__value_type
github xtreemfs / babudb / replication / share / yidl / src / yidl / target.py View on Github external
def getIdentifier( self ): return self.getName()    
    def getType( self ): return self.__type    


class Constant(Declaration):
    def __init__( self, scope, type, qname, value ):
        Declaration.__init__( self, scope, type, qname )
        self.__value = value
        
    def __repr__( self ):
        return "const " + Declaration.__repr__( self )

    def getValue( self ): return self.__value


class EnumeratedType(Type):
    def __init__( self, *args, **kwds ):
        Type.__init__( self, *args, **kwds )
        self.__enumerators = []
    
    def __repr__( self ):
        return self.__class__.__name__ + " " + self.getName() + "\n{\n" + "\n".join( [" " + repr( enumerator ) + ";" for enumerator in self.getEnumerators()] ) + "\n};"
                
    def addEnumerator( self, enumerator, *args, **kwds ): return self._addConstruct( enumerator, "Enumerator", Construct, self.__enumerators, *args, **kwds )
    def getEnumerators( self ): return self.__enumerators

class Enumerator(Construct):
    def __init__( self, scope, qname, value=None ):
        Construct.__init__( self, scope, qname )
        self.__value = value

    def getIdentifier( self ): return self.getName()
github xtreemfs / babudb / replication / share / yidl / src / yidl / target.py View on Github external
def __init__( self, scope, qname, tag, value_type ):
        Type.__init__( self, scope, qname, tag )
        self.__value_type = value_type

    def __repr__( self ):
        return self.__class__.__name__ + " " + self.getName() + "<" + repr( self.getValueType() ) + ">;"        

    def getMarshallerTypeName( self ): return "Sequence"
    def getValueType( self ): return self.__value_type


class StringType(Type):
    def getMarshallerTypeName( self ): return "String"    

        
class StructType(Type):
    def __init__( self, scope, qname, tag=0, parent_type_names=None, members=[] ):
        Type.__init__( self, scope, qname, tag )
        self.__parent_type_names = parent_type_names is not None and parent_type_names or []
        if members is None: # A forward declaration or an undefined type
            self.__members = None
        else:
            self.__members = []            
            if len( members ) > 0:      
                for member in members:
                    assert isinstance( member, Declaration )
                    self.__members.append( member )

    def __repr__( self ):
        return self.__class__.__name__ + " " + self.getName() + "\n{\n" + "\n".join( [" " + repr( member ) + ";" for member in self.getMembers()] ) + "\n};"        

    def addMember( self, member, *args, **kwds ): return self._addConstruct( member, "StructTypeMember", Declaration, self.__members, *args, **kwds )