~ubuntu-branches/ubuntu/trusty/ctioga/trusty

« back to all changes in this revision

Viewing changes to Backends/lib/Backends/filters/filter.rb

  • Committer: Bazaar Package Importer
  • Author(s): Vincent Fourmond, Arnaud Cornet, Vincent Fourmond
  • Date: 2008-02-26 18:52:06 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20080226185206-apuosaxrvp4rpxaz
Tags: 1.7-1
[ Arnaud Cornet ]
* Use new Homepage dpkg header.

[ Vincent Fourmond ]
* New 'upstream' release
* Already conforms to standards version 3.7.3
* Added 11-manpage-typo to fix a very small typo in the manual page
  that makes lintian unhappy

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# filter.rb : The base class for filters
 
2
# Copyright (C) 2006 Vincent Fourmond
 
3
 
 
4
# This program is free software; you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation; either version 2 of the License, or
 
7
# (at your option) any later version.
 
8
 
 
9
# This program is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU General Public License for more details.
 
13
 
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with this program; if not, write to the Free Software
 
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
17
 
 
18
 
 
19
module SciYAG
 
20
 
 
21
  module Backends
 
22
 
 
23
    #  The base class for filters. Just an interface, in the java meaning of
 
24
    #  the term. A filter just provides a function to apply itself.
 
25
    class Filter
 
26
      # Import the main description functions into the appropriate
 
27
      # namespaces
 
28
      extend  Descriptions::DescriptionExtend
 
29
      include Descriptions::DescriptionInclude
 
30
 
 
31
 
 
32
      def initialize
 
33
      end
 
34
 
 
35
      # Creates a description object with the given texts and associates
 
36
      # it with the class. To be used in Filter subclasses, simply this way:
 
37
      #
 
38
      #  describe "biniou", "Biniou filter", "A filter to take out Binious"
 
39
      #
 
40
      # Please remember also that if you don't set a description for
 
41
      # your Filter, it will most likely be of no use to anyone...
 
42
 
 
43
      def Filter.describe(name, longname, desc)
 
44
        d = FilterDescription.new(self,name, longname, desc)
 
45
        set_description(d)
 
46
        register_description(d)
 
47
      end
 
48
 
 
49
      # Gets a Function (or assimilate ?) and applies the filter on them.
 
50
      # The functions  *should not modify any data in ary*.
 
51
      # By default, the mechanism is to make a copy of the data and apply
 
52
      # apply! on it.
 
53
      def apply(a)
 
54
        f = Dobjects::Function.new(a.x.dup, a.y.dup)
 
55
        apply!(f)
 
56
        return f
 
57
      end
 
58
 
 
59
      # This version modifies directly the Function inside the +f+. 
 
60
      def apply!(func)
 
61
        return func
 
62
      end
 
63
    end
 
64
 
 
65
    # Specializes Descriptions for filters
 
66
    class FilterDescription < Descriptions::Description
 
67
      
 
68
    end
 
69
  end
 
70
end