Update of /cvsroot/objecthandler/ObjectHandler/oh
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv19553/oh
Modified Files:
objecthandler.cpp objecthandler.hpp utilities.hpp
Log Message:
convert object IDs to upper case
Index: utilities.hpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/oh/utilities.hpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** utilities.hpp 4 Oct 2006 09:37:43 -0000 1.12
--- utilities.hpp 26 Oct 2006 10:14:41 -0000 1.13
***************
*** 80,88 ****
// some basic utilities
std::vector<std::string> split(
const std::string &line,
unsigned int maxRequired,
const std::string &delim);
! std::string uppercase(const std::string& s);
//@}
--- 80,90 ----
// some basic utilities
+
std::vector<std::string> split(
const std::string &line,
unsigned int maxRequired,
const std::string &delim);
!
! std::string uppercase(const std::string&);
//@}
***************
*** 90,92 ****
#endif
-
--- 92,93 ----
Index: objecthandler.hpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/oh/objecthandler.hpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** objecthandler.hpp 7 Oct 2006 16:07:23 -0000 1.15
--- objecthandler.hpp 26 Oct 2006 10:14:41 -0000 1.16
***************
*** 47,52 ****
/*! Any existing Object with that ID is deleted.
*/
! virtual std::string storeObject(std::string objectID,
! const boost::shared_ptr < Object > &object);
//! Retrieve Object with given ID.
--- 47,52 ----
/*! Any existing Object with that ID is deleted.
*/
! virtual std::string storeObject(const std::string &objectID,
! const boost::shared_ptr<Object> &object);
//! Retrieve Object with given ID.
***************
*** 55,59 ****
virtual boost::shared_ptr<Object> retrieveObjectImpl(const std::string &objectID) const;
! template < typename T >
void retrieveObject(boost::shared_ptr<T> &ret, const std::string &id) {
boost::shared_ptr<Object> object = retrieveObjectImpl(id);
--- 55,59 ----
virtual boost::shared_ptr<Object> retrieveObjectImpl(const std::string &objectID) const;
! template <class T>
void retrieveObject(boost::shared_ptr<T> &ret, const std::string &id) {
boost::shared_ptr<Object> object = retrieveObjectImpl(id);
***************
*** 96,101 ****
/*! Returns empty list if repository is empty.
*/
! virtual const std::vector < std::string > listObjectIDs(
! const std::string regex = "");
//@}
protected:
--- 96,101 ----
/*! Returns empty list if repository is empty.
*/
! virtual const std::vector<std::string> listObjectIDs(
! const std::string ®ex = "");
//@}
protected:
***************
*** 109,113 ****
template <class ObjectClass>
std::vector<boost::shared_ptr<ObjectClass> > getObjectVector(
! std::vector<std::string> objectIDs) {
std::vector<boost::shared_ptr<ObjectClass> > ret;
for (std::vector<std::string>::const_iterator i = objectIDs.begin();
--- 109,113 ----
template <class ObjectClass>
std::vector<boost::shared_ptr<ObjectClass> > getObjectVector(
! const std::vector<std::string> &objectIDs) {
std::vector<boost::shared_ptr<ObjectClass> > ret;
for (std::vector<std::string>::const_iterator i = objectIDs.begin();
Index: objecthandler.cpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/oh/objecthandler.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** objecthandler.cpp 4 Oct 2006 09:37:43 -0000 1.4
--- objecthandler.cpp 26 Oct 2006 10:14:41 -0000 1.5
***************
*** 23,26 ****
--- 23,27 ----
#include <oh/objecthandler.hpp>
#include <oh/exception.hpp>
+ #include <oh/utilities.hpp>
#include <ostream>
#include <sstream>
***************
*** 45,62 ****
ObjectHandler &ObjectHandler::instance() {
! if (instance_) {
! return *instance_;
! } else
throw Exception("Attempt to reference uninitialized ObjectHandler object");
}
! 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;
--- 46,68 ----
ObjectHandler &ObjectHandler::instance() {
! if (instance_)
! return *instance_;
! else
throw Exception("Attempt to reference uninitialized ObjectHandler object");
}
! std::string ObjectHandler::storeObject(
! const std::string &objectID,
const boost::shared_ptr<Object> &object) {
! std::string objectIDUpper = uppercase(objectID);
! repository_[objectIDUpper] = object;
! return objectIDUpper;
}
! boost::shared_ptr<Object> ObjectHandler::retrieveObjectImpl(
! const std::string &objectID) const {
! std::string objectIDUpper = uppercase(objectID);
! std::map<std::string, boost::shared_ptr<Object> >::const_iterator result
! = repository_.find(objectIDUpper);
if (result == repository_.end()) {
std::ostringstream msg;
***************
*** 69,73 ****
void ObjectHandler::deleteObject(const std::string &objectID) {
! repository_.erase(objectID);
}
--- 75,80 ----
void ObjectHandler::deleteObject(const std::string &objectID) {
! std::string objectIDUpper = uppercase(objectID);
! repository_.erase(objectIDUpper);
}
***************
*** 76,80 ****
repository_.clear();
} else {
! std::map < std::string, boost::shared_ptr < Object > >::const_iterator iter_current, iter_previous;
iter_current = repository_.begin();
while (iter_current != repository_.end()) {
--- 83,87 ----
repository_.clear();
} else {
! std::map<std::string, boost::shared_ptr<Object> >::const_iterator iter_current, iter_previous;
iter_current = repository_.begin();
while (iter_current != repository_.end()) {
***************
*** 82,86 ****
iter_current++;
std::string key = iter_previous->first;
! boost::shared_ptr < Object > object = iter_previous->second;
if (!object->permanent()) {
repository_.erase(key);
--- 89,93 ----
iter_current++;
std::string key = iter_previous->first;
! boost::shared_ptr<Object> object = iter_previous->second;
if (!object->permanent()) {
repository_.erase(key);
***************
*** 103,108 ****
}
! 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++)
--- 110,116 ----
}
! const std::vector<std::string> ObjectHandler::listObjectIDs(
! const std::string ®ex) {
! 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++)
***************
*** 119,122 ****
--- 127,131 ----
}
+ // this function assumes that objectID has already been converted to uppercase
void ObjectHandler::checkName(const std::string &objectID) {
std::map<std::string, boost::shared_ptr<Object> >::const_iterator result =
|