Class: EventCache

Inherits:
Object
  • Object
show all
Includes:
Eprint, Singleton
Defined in:
lib/Common/EventCache.rb

Overview

this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint([email protected])

Constant Summary

Constants included from Eprint

Eprint::DOMAIN, Eprint::LEVEL

Instance Method Summary collapse

Methods included from Eprint

#ecode, #edebug, #eerror, #einfo, #enormal, #eprint, #ewarn, #gtk_set_edebug, #set_edebug, #tell_exception

Instance Method Details

#gtkobject_events(gtkobjectid, event_name) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/Common/EventCache.rb', line 9

def gtkobject_events(gtkobjectid,event_name)
  goid=gtkobjectid.to_i
  @events=Hash.new if @events.nil?
  @events.delete(goid) if event_name.nil?
  unless @events.has_key?(goid)
    @events[goid]=Hash.new 
    #load events for object
    a=ManqodDB.instance.cache.get("ev#{gtkobjectid}")
    a=Hash.new unless a.class.name == "Hash"

    a.each_pair{|ev_name,ev|
      @events[goid][ev_name]=ev.to_a
    } 
    einfo("loaded #{a.size} events for #{goid}","events")
  end
  unless @events[goid].nil? || @events[goid][event_name].nil?
    einfo("serving from cache #{event_name} events for #{goid}","events")
    @events[goid][event_name].each{|event_command|
      yield event_command
    }
  end
end

#reload_events(gtkobjectid) ⇒ Object



32
33
34
35
36
37
# File 'lib/Common/EventCache.rb', line 32

def reload_events(gtkobjectid)
  @events=Hash.new if @events.nil?
  @events[gtkobjectid.to_i]=Hash.new unless @events.has_key?(gtkobjectid.to_i)
  gtkobject_events(gtkobjectid.to_i,nil)
  einfo("reloaded #{gtkobjectid}","events")
end

#to_sObject



39
# File 'lib/Common/EventCache.rb', line 39

def to_s;"EventCache";end