summaryrefslogtreecommitdiff
path: root/data_tree.rb
blob: 260f14a39e5c87cc49b90109ce6a3ebaed16bfce (plain)
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
# data_tree: holds a data structure, filled by the parser, used by
# the dumper
#
# Copyright (C) 2006,2007,2008
# Frederik Deweerdt <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

require 'node.rb'

class DataTree
  attr_reader :nodes, :tables, :enums, :types , :notifications
  def initialize
    @nodes = []
    @enums = []
    @tables = []
    @notifications = []
    @types = {}
  end#initialize

  def addType(type, basetype)
    @types.store(type, basetype)
  end#addEnum

  def addEnum(enum)
    @enums << enum
  end#addEnum

  def addNode(node)
    @nodes << node
  end#addNode

  def addTable(table)
    @tables << table
  end#addNode

  def addNotification(notification)
    @notifications << notification
  end#addNode

  def to_s
    @nodes.to_s + @enums.to_s + @tables.to_s + @types.to_s + @notifications.to_s
  end#hash

  def is_empty?
    return (@nodes.size == 0 \
            and @tables.size == 0 \
            and @types.keys.size == 0 \
            and @notifications.size == 0)
  end#empty?
end#class DataTree