Class: OMF::Rete::Store::PredicateStore
- Inherits:
-
Object
- Object
- OMF::Rete::Store::PredicateStore
- Includes:
- OMF::Rete::Store
- Defined in:
- lib/omf_rete/store/predicate_store.rb
Overview
This store supports ‘predicate’ tuples. The predicate of a tuple is identified by it’s first element and each predicate can have a different scheme (tuple length). Each predicate needs to be registered through ‘registerPredicate’.
Subscriptions and ‘find’ queries need to name the predicate. In other words, they CANNOT span multiple predicates.
Constant Summary
Constants included from OMF::Rete::Store
Instance Method Summary collapse
- #addTuple(tarray) ⇒ Object
- #confirmLength(tuple) ⇒ Object
- #find(pattern) ⇒ Object
-
#initialize(opts = {}) ⇒ PredicateStore
constructor
A new instance of PredicateStore.
-
#registerPredicate(pred_name, length, opts = {}) ⇒ Object
Register a new predicate ‘pred_name’ whose tuples are of ‘length’.
-
#registerPredicateStore(pred_name, store) ⇒ Object
Register a ‘store’ for predicate ‘pred_name’.
-
#registerTSet(tset, pattern) ⇒ Object
Store API ###.
- #removeTuple(tarray) ⇒ Object
- #to_s ⇒ Object
Methods included from OMF::Rete::Store
#add, create, #createTSet, #on_query, #query, #remove, #subscribe, #unsubscribe
Constructor Details
#initialize(opts = {}) ⇒ PredicateStore
Returns a new instance of PredicateStore.
32 33 34 35 |
# File 'lib/omf_rete/store/predicate_store.rb', line 32 def initialize(opts = {}) store_initialize() @stores = {} end |
Instance Method Details
#addTuple(tarray) ⇒ Object
65 66 67 |
# File 'lib/omf_rete/store/predicate_store.rb', line 65 def addTuple(tarray) get_store(tarray).addTuple(tarray) end |
#confirmLength(tuple) ⇒ Object
81 82 83 |
# File 'lib/omf_rete/store/predicate_store.rb', line 81 def confirmLength(tuple) tuple.is_a?(Array) && get_store(tuple).confirmLength(tuple) end |
#find(pattern) ⇒ Object
73 74 75 |
# File 'lib/omf_rete/store/predicate_store.rb', line 73 def find(pattern) get_store(pattern).find(pattern) end |
#registerPredicate(pred_name, length, opts = {}) ⇒ Object
Register a new predicate ‘pred_name’ whose tuples are of ‘length’.
39 40 41 42 43 44 45 |
# File 'lib/omf_rete/store/predicate_store.rb', line 39 def registerPredicate(pred_name, length, opts = {}) pred_name = pred_name.to_sym if @stores.key? pred_name raise AlreadyRegisteredPredicateException.new(pred_name) end @stores[pred_name] = NamedAlphaStore.new(pred_name, length, opts) end |
#registerPredicateStore(pred_name, store) ⇒ Object
Register a ‘store’ for predicate ‘pred_name’.
49 50 51 52 53 54 55 |
# File 'lib/omf_rete/store/predicate_store.rb', line 49 def registerPredicateStore(pred_name, store) pred_name = pred_name.to_sym if @stores.key? pred_name raise AlreadyRegisteredPredicateException.new(pred_name) end @stores[pred_name] = store end |
#registerTSet(tset, pattern) ⇒ Object
Store API ###
59 60 61 62 63 |
# File 'lib/omf_rete/store/predicate_store.rb', line 59 def registerTSet(tset, pattern) tset = get_store(pattern).registerTSet(tset, pattern) #puts ">>> Register tset - #{pattern} - #{tset}" tset end |
#removeTuple(tarray) ⇒ Object
69 70 71 |
# File 'lib/omf_rete/store/predicate_store.rb', line 69 def removeTuple(tarray) get_store(tarray).removeTuple(tarray) end |
#to_s ⇒ Object
77 78 79 |
# File 'lib/omf_rete/store/predicate_store.rb', line 77 def to_s() "Predicate Store" end |