1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
# backends.rb, copyright (c) 2006 by Vincent Fourmond:
# The module handling the communication with backends.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details (in the COPYING file).
# The backend structure...
require 'SciYAG/backends'
require 'MetaBuilder/factory'
require 'CTioga/utils'
module CTioga
Version::register_svn_info('$Revision: 696 $', '$Date: 2007-12-06 20:59:20 +0100 (Thu, 06 Dec 2007) $')
# This module handles all manipulations of backends.
module Backends
include SciYAG
# Initializes the backend structure.
def init_backend_structure
@backend_factory =
MetaBuilder::Factories::UniqueFactory.new(SciYAG::Backends::Backend,
'text')
SciYAG::Backends::Backend.logger = self.logger
end
def backend
@backend_factory.current
end
def backends
@backend_factory.instances
end
def set_backend(str)
@backend_factory.current = str
end
# Push a filter onto the current backend
def current_push_filter(filter)
backend.push_xy_filter(filter)
end
# Fills an OptionParser with the apppropriate stuff to
# deal with backends:
def prepare_backend_options(op)
op.separator "\nHow to select backends, and their options:"
@backend_factory.option_parser_factory(op)
op.separator "\nFilters to apply onto data:"
for filter_desc in SciYAG::Backends::Filter.description_list
filter_desc.parser_instantiate_option(op,
self,
:current_push_filter)
end
op.on("--filter-pop", "Removes the last filter pushed " +
"onto the current backend") do
backend.pop_xy_filter
end
op.on("--filter-clear", "Removes all filters applying " +
"to the current backend") do
backend.clear_xy_filters
end
end
# Interprets the +set+ with the current backend and returns the data
def xy_data_set(set)
return backend.xy_data(set)
end
# Expands the current set according to the current's backend rules
def expand_spec(spec)
backend.expand_sets(spec)
end
end
end
|