module Sbuilder class ParamSetLoader attr_reader :factory # to create stuff attr_accessor :controller # get sets when load starts # ------------------------------------------------------------------ # mixer PROGNAME = "ParamSetLoader" # progname for logger include Sbuilder::Utils::MyLogger # mix logger # ------------------------------------------------------------------ # constructore def initialize( factory, options = {} ) @logger = getLogger( PROGNAME, options ) @logger.info( "#{__method__} initialized" ) @factory = factory end # @param loaderDef [Hash] adding configuration for loader (override) def configure( loaderDef ) doConfigure( loaderDef ) end def doConfigure( loaderDef ) msg = "Sub class should implement doConfigure -method" @logger.error( "#{__method__} #{msg}" ) raise NoMethodError.new( msg ) end # ------------------------------------------------------------------ # load paramset from 'fileUri' def load( controller, fileUri, cacheFile=nil ) # controller which control loading @controller = controller begin loaded = doLoad( fileUri, cacheFile ) rescue Exception => e msg = "Exception '#{e}' when loading fileUri '#{fileUri}'" @logger.error( "#{__method__} #{msg}" ) puts msg raise e end # # iterate && report to controller # loaded.each do |paramSet| # controller.interfaceEncountered( paramSet ) # end end def createParamSet( type ) factory.createParamSet( type ) end def createParameter( type ) factory.createParameter( type ) end # ------------------------------------------------------------------ # sub-class should implement the doload method def doLoad( fileUri, cacheFile=nil ) msg = "Sub class should implement doLoad -method" @logger.error( "#{__method__} #{msg}" ) raise NoMethodError.new( msg ) end end # class ParamSetLoader end # module