DataManager.cc

Go to the documentation of this file.
00001 /*
00002  * This file is part of openSDK.
00003  *
00004  * Copyright (C) 2006-2007 openSDK team
00005  *
00006  * openSDK is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; version 2.
00009  *
00010  * openSDK is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with openSDK; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  *
00019  *     $Id: DataManager.cc,v 1.3 2007/04/27 10:28:42 nuno-lopes Exp $
00020  */
00021 
00022 #include <OPENR/DataManager.h>
00023 
00024 DataManager::DataManager()
00025 {
00026         // do nothing
00027 }
00028 
00029 
00030 DataManager::~DataManager()
00031 {
00032         ClearAll();
00033 }
00034 
00035 
00036 void DataManager::Register(const SubjectID& subject, RCRegion *myRCR, RCRegion *srcRCR)
00037 {
00038         dataInfo_.push_back(DataInfo(subject, myRCR, srcRCR));
00039 }
00040 
00041 
00042  void DataManager::InitUnregistration()
00043 {
00044         // do nothing
00045 }
00046 
00047 
00048 DataInfo DataManager::Unregister(const SubjectID& subject)
00049 {
00050         DataInfo info;
00051 
00052         for (list<DataInfo>::iterator it = dataInfo_.begin(); it != dataInfo_.end(); ) {
00053                 if ((*it).subject == subject) {
00054                         info = (*it);
00055                         (*it).myRCRegion->RemoveReference();
00056                         it = dataInfo_.erase(it);
00057                 } else {
00058                         ++it;
00059                 }
00060         }
00061 
00062         return info;
00063 }
00064 
00065 
00066 void DataManager::Clear(const SubjectID& subject)
00067 {
00068         for (list<DataInfo>::iterator it = dataInfo_.begin(); it != dataInfo_.end(); ) {
00069                 if ((*it).subject == subject) {
00070                         it = dataInfo_.erase(it);
00071                 } else {
00072                         ++it;
00073                 }
00074         }
00075 }
00076 
00077 
00078 void DataManager::ClearAll()
00079 {
00080         dataInfo_.clear();
00081 }
00082 
00083 
00084 SubjectID DataManager::FindSender(RCRegion *ptr) const
00085 {
00086         for (list<DataInfo>::const_iterator it = dataInfo_.begin(); it != dataInfo_.end(); ++it) {
00087                 if ((*it).srcRCRegion == ptr) {
00088                         return (*it).subject;
00089                 }
00090         }
00091 
00092         return SubjectID();
00093 }

Generated on Sun Dec 2 23:04:28 2007 for openSDK by  doxygen 1.3.9.1