# Copyright (C) 2003-2005 Kouichirou Eto, All rights reserved.

$LOAD_PATH << "../../lib" unless $LOAD_PATH.include?("../../lib")
#require "qwik/farm"

module Qwik
  class ServerMemory
    def initialize(config)
      @config = config
      @hash = {}
    end
    def [](k)		@hash[k];	end
    def []=(k, v)	@hash[k] = v; end

    # farm
    def farm
      @farm = Farm.new(@config, self) unless defined? @farm
      @farm
    end

    # template
    def template
      @template = TemplateFactory.new(@config) unless defined? @template
      @template
    end

    # catalog
    def catalog
#      @catalog = Catalog.new(@config) unless defined? @catalog
#      @catalog
      @catalog = CatalogFactory.new unless defined? @catalog
      @catalog
    end

    # act-qrcode
    def qrcode
      @qrcode = QRCodeMemory.new(@config, self) unless defined? @qrcode
      @qrcode
    end

    # act-theme
    def theme
      @theme = ThemeFactory.new(@config) unless defined? @theme
      @theme
    end

    # act-session
    def sessiondb
      @sessiondb = SessionDB.new(@config) unless defined? @sessiondb
      @sessiondb
    end

    # password
    def passgen
      @passgen = PasswordGenerator.new(@config) unless defined? @passgen
      @passgen
    end

    # monitor
    def monitor
      @monitor = SiteMonitor.new(@config) unless defined? @monitor
      @monitor
    end
  end
end
