ObjectStorage.cpp
Go to the documentation of this file.
00001 #include "wire/storage/ObjectStorage.h"
00002 
00003 #include "wire/storage/KnowledgeDatabase.h"
00004 #include "wire/storage/SemanticObject.h"
00005 #include "wire/core/Evidence.h"
00006 
00007 using namespace std;
00008 
00009 namespace mhf {
00010 
00011 ObjectStorage* ObjectStorage::instance_ = 0;
00012 
00013 ObjectStorage& ObjectStorage::getInstance() {
00014     if (instance_) {
00015         return *instance_;
00016     }
00017     instance_ = new ObjectStorage();
00018     return *instance_;
00019 }
00020 
00021 ObjectStorage::ObjectStorage() : ID_(0), knowledge_db_(KnowledgeDatabase::getInstance()) {
00022 
00023 }
00024 
00025 ObjectStorage::~ObjectStorage() {
00026 
00027 }
00028 
00029 void ObjectStorage::addObject(SemanticObject* obj) {
00030     objects_.push_back(obj);
00031     obj->it_obj_storage_ = --objects_.end();
00032 }
00033 
00034 void ObjectStorage::removeObject(SemanticObject& obj) {
00035     objects_.erase(obj.it_obj_storage_);
00036 }
00037 
00038 long ObjectStorage::getUniqueID() {
00039     return ID_++;
00040 }
00041 
00042 void ObjectStorage::match(const Evidence& ev) {
00043 
00044     //cout << endl << "ObjectStorage::match" << endl;
00045 
00046     for(list<SemanticObject*>::iterator it_obj = objects_.begin(); it_obj != objects_.end(); ++it_obj) {
00047         SemanticObject& obj = **it_obj;
00048         obj.propagate(ev.getTimestamp());
00049     }
00050 
00051     for(list<SemanticObject*>::iterator it_obj = objects_.begin(); it_obj != objects_.end(); ++it_obj) {
00052         SemanticObject& obj = **it_obj;
00053 
00054         double prob_existing = KnowledgeDatabase::getInstance().getProbabilityExisting(ev, obj);
00055         if (prob_existing > 0) {
00056 
00057             //cout << "Adding evidence " << &ev << " to object " << &obj << endl;
00058 
00059             obj.addPotentialAssignment(ev, prob_existing);
00060         }
00061     }
00062 }
00063 
00064 }


wire_core
Author(s): Sjoerd van den Dries, Jos Elfring
autogenerated on Tue Jan 7 2014 11:43:19