Update of /cvsroot/objecthandler/ObjectHandler/oh
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv29706/oh
Modified Files:
object.hpp objecthandler.cpp objecthandler.hpp utilities.cpp
utilities.hpp
Log Message:
InstanceName replaced with ObjectID
Index: utilities.cpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/oh/utilities.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** utilities.cpp 12 Jul 2006 14:02:23 -0000 1.12
--- utilities.cpp 17 Jul 2006 10:11:39 -0000 1.13
***************
*** 62,74 ****
}
! void logObject(const std::string &instanceName) {
std::ostringstream msg;
boost::shared_ptr<Object> object =
! ObjectHandler::instance().retrieveObjectImpl(instanceName);
if (object) {
! msg << "log dump of object with instance name = " << instanceName << std::endl;
msg << *object.get();
} else {
! msg << "no object in repository with instance name = " << instanceName << std::endl;
}
Logger::instance().logMessage(msg.str());
--- 62,74 ----
}
! void logObject(const std::string &objectID) {
std::ostringstream msg;
boost::shared_ptr<Object> object =
! ObjectHandler::instance().retrieveObjectImpl(objectID);
if (object) {
! msg << "log dump of object with instance name = " << objectID << std::endl;
msg << *object.get();
} else {
! msg << "no object in repository with instance name = " << objectID << std::endl;
}
Logger::instance().logMessage(msg.str());
Index: object.hpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/oh/object.hpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** object.hpp 14 Jul 2006 08:16:51 -0000 1.10
--- object.hpp 17 Jul 2006 10:11:39 -0000 1.11
***************
*** 69,73 ****
/*! Construct an Object.
To store the resulting Object in the ObjectHandler, call
! ObjectHandler::instance().storeObject(instanceName, object);
*/
Object() : anonymous_(false), permanent_(false) {};
--- 69,73 ----
/*! Construct an Object.
To store the resulting Object in the ObjectHandler, call
! ObjectHandler::instance().storeObject(objectID, object);
*/
Object() : anonymous_(false), permanent_(false) {};
Index: utilities.hpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/oh/utilities.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** utilities.hpp 12 Jul 2006 14:02:23 -0000 1.9
--- utilities.hpp 17 Jul 2006 10:11:39 -0000 1.10
***************
*** 73,77 ****
if no object is found with given instance name.
*/
! void logObject(const std::string &instanceName);
//! Write all Objects to log file.
--- 73,77 ----
if no object is found with given instance name.
*/
! void logObject(const std::string &objectID);
//! Write all Objects to log file.
Index: objecthandler.hpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/oh/objecthandler.hpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** objecthandler.hpp 19 Jun 2006 11:02:38 -0000 1.8
--- objecthandler.hpp 17 Jul 2006 10:11:39 -0000 1.9
***************
*** 47,51 ****
/*! Any existing Object with that instance name is deleted.
*/
! virtual std::string storeObject(std::string instanceName,
const boost::shared_ptr < Object > &object);
--- 47,51 ----
/*! Any existing Object with that instance name is deleted.
*/
! virtual std::string storeObject(std::string objectID,
const boost::shared_ptr < Object > &object);
***************
*** 53,57 ****
/*! Throws exception if no Object exists with that instance name.
*/
! virtual boost::shared_ptr<Object> retrieveObjectImpl(const std::string &instanceName) const;
template < typename T >
--- 53,57 ----
/*! Throws exception if no Object exists with that instance name.
*/
! virtual boost::shared_ptr<Object> retrieveObjectImpl(const std::string &objectID) const;
template < typename T >
***************
*** 76,80 ****
/*! Does nothing if no Object exists with that instance name.
*/
! virtual void deleteObject(const std::string &instanceName);
//! Delete all Objects in repository.
--- 76,80 ----
/*! Does nothing if no Object exists with that instance name.
*/
! virtual void deleteObject(const std::string &objectID);
//! Delete all Objects in repository.
***************
*** 98,102 ****
/*! Returns empty list if repository is empty.
*/
! virtual const std::vector < std::string > listInstanceNames(
const std::string regex = "");
--- 98,102 ----
/*! Returns empty list if repository is empty.
*/
! virtual const std::vector < std::string > listObjectIDs(
const std::string regex = "");
***************
*** 110,114 ****
protected:
static ObjectHandler *instance_;
! void checkName(const std::string &instanceName);
std::string lastErrorMessage_;
};
--- 110,114 ----
protected:
static ObjectHandler *instance_;
! void checkName(const std::string &objectID);
std::string lastErrorMessage_;
};
Index: objecthandler.cpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/oh/objecthandler.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** objecthandler.cpp 18 Jun 2006 13:41:51 -0000 1.2
--- objecthandler.cpp 17 Jul 2006 10:11:39 -0000 1.3
***************
*** 51,66 ****
}
! std::string ObjectHandler::storeObject(std::string instanceName,
const boost::shared_ptr<Object> &object) {
! repository_[instanceName] = object;
! return instanceName;
}
! boost::shared_ptr<Object> ObjectHandler::retrieveObjectImpl(const std::string &instanceName) const {
! std::map<std::string, boost::shared_ptr<Object> >::const_iterator result = repository_.find(instanceName);
if (result == repository_.end()) {
std::ostringstream msg;
msg << "ObjectHandler error: attempt to retrieve object "
! << "with unknown instance name '" << instanceName << "'";
throw Exception(msg.str());
} else
--- 51,66 ----
}
! std::string ObjectHandler::storeObject(std::string objectID,
const boost::shared_ptr<Object> &object) {
! repository_[objectID] = object;
! return objectID;
}
! boost::shared_ptr<Object> ObjectHandler::retrieveObjectImpl(const std::string &objectID) const {
! std::map<std::string, boost::shared_ptr<Object> >::const_iterator result = repository_.find(objectID);
if (result == repository_.end()) {
std::ostringstream msg;
msg << "ObjectHandler error: attempt to retrieve object "
! << "with unknown instance name '" << objectID << "'";
throw Exception(msg.str());
} else
***************
*** 68,73 ****
}
! void ObjectHandler::deleteObject(const std::string &instanceName) {
! repository_.erase(instanceName);
}
--- 68,73 ----
}
! void ObjectHandler::deleteObject(const std::string &objectID) {
! repository_.erase(objectID);
}
***************
*** 95,99 ****
i!=repository_.end(); i++) {
boost::shared_ptr<Object> object = i->second;
! out << "Object with instanceName = " << i->first << ":" << std::endl << *object.get();
}
}
--- 95,99 ----
i!=repository_.end(); i++) {
boost::shared_ptr<Object> object = i->second;
! out << "Object with ID = " << i->first << ":" << std::endl << *object.get();
}
}
***************
*** 103,129 ****
}
! const std::vector < std::string > ObjectHandler::listInstanceNames(const std::string regex) {
! std::vector < std::string > instanceNames;
if (regex.empty()) {
for (std::map<std::string, boost::shared_ptr<Object> >::const_iterator i=repository_.begin(); i!=repository_.end(); i++)
! instanceNames.push_back(i->first);
} else {
boost::regex r(regex);
for (std::map<std::string, boost::shared_ptr<Object> >::const_iterator i=repository_.begin(); i!=repository_.end(); i++) {
! std::string instanceName = i->first;
! if (regex_match(instanceName, r)) instanceNames.push_back(instanceName);
}
}
! std::sort(instanceNames.begin(), instanceNames.end());
! return instanceNames;
}
! void ObjectHandler::checkName(const std::string &instanceName) {
std::map<std::string, boost::shared_ptr<Object> >::const_iterator result =
! repository_.find(instanceName);
if (result != repository_.end()) {
std::ostringstream msg;
msg << "ObjectHandler error: cannot create object "
! "with instance name '" << instanceName <<
"' because an object with that name already exists";
throw Exception(msg.str());
--- 103,129 ----
}
! const std::vector < std::string > ObjectHandler::listObjectIDs(const std::string regex) {
! std::vector < std::string > objectIDs;
if (regex.empty()) {
for (std::map<std::string, boost::shared_ptr<Object> >::const_iterator i=repository_.begin(); i!=repository_.end(); i++)
! objectIDs.push_back(i->first);
} else {
boost::regex r(regex);
for (std::map<std::string, boost::shared_ptr<Object> >::const_iterator i=repository_.begin(); i!=repository_.end(); i++) {
! std::string objectID = i->first;
! if (regex_match(objectID, r)) objectIDs.push_back(objectID);
}
}
! std::sort(objectIDs.begin(), objectIDs.end());
! return objectIDs;
}
! void ObjectHandler::checkName(const std::string &objectID) {
std::map<std::string, boost::shared_ptr<Object> >::const_iterator result =
! repository_.find(objectID);
if (result != repository_.end()) {
std::ostringstream msg;
msg << "ObjectHandler error: cannot create object "
! "with instance name '" << objectID <<
"' because an object with that name already exists";
throw Exception(msg.str());
|