summaryrefslogtreecommitdiff
path: root/cpp/rubygen/0-10/handlers.rb
blob: c23eb5faf4c1d9f51587c3b2b52d4f65da375bfb (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
#!/usr/bin/env ruby
$: << ".."                      # Include .. in load path
require 'cppgen'

class GenHandlers < CppGen
  def initialize(outdir, amqp)
    super(outdir, amqp)
    @ns="qpid::amqp_#{@amqp.version.bars}"
    @dir="qpid/amqp_#{@amqp.version.bars}"
  end

  def action_handler(type, actions)
    genl
    bases=actions.map { |a| "public #{a.fqclassname}::Handler" }
    struct("#{type}Handler", *bases) { }
  end

  def generate()
    h_file("#{@dir}/handlers.h") {
      include "specification"
      namespace("#{@ns}") { 
        action_handler "Command", @amqp.collect_all(AmqpCommand)
        action_handler "Control", @amqp.collect_all(AmqpControl)
      }
    }
  end
end

GenHandlers.new($outdir, $amqp).generate()