Update of /cvsroot/objecthandler/ObjectHandler/ohxl
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv4466/ohxl
Modified Files:
objecthandlerxl.cpp objecthandlerxl.hpp
Log Message:
increase to 4 billion the max value of autogenerated object IDs
Index: objecthandlerxl.cpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/ohxl/objecthandlerxl.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** objecthandlerxl.cpp 18 Jun 2006 13:41:51 -0000 1.8
--- objecthandlerxl.cpp 28 Jun 2006 14:28:32 -0000 1.9
***************
*** 31,39 ****
#include <iomanip>
#include <sstream>
! #include <cmath>
namespace ObjHandler {
! int ObjectHandlerXL::instanceNameCount_ = 0;
// std::map cannot be exported across DLL boundaries
--- 31,39 ----
#include <iomanip>
#include <sstream>
! #include <limits.h>
namespace ObjHandler {
! unsigned long ObjectHandlerXL::instanceNameCount_ = 0;
// std::map cannot be exported across DLL boundaries
***************
*** 44,53 ****
if (instance_) {
ObjectHandlerXL *ret = dynamic_cast<ObjectHandlerXL*>(instance_);
! if (ret)
! return *ret;
! else
! throw Exception("Attempt to reference uninitialized ObjectHandlerXL object");
! } else
! throw Exception("Attempt to reference uninitialized ObjectHandlerXL object");
}
--- 44,50 ----
if (instance_) {
ObjectHandlerXL *ret = dynamic_cast<ObjectHandlerXL*>(instance_);
! if (ret) return *ret;
! }
! throw Exception("Attempt to reference uninitialized ObjectHandlerXL object");
}
***************
*** 142,151 ****
std::string ObjectHandlerXL::generateInstanceName() {
static const int COUNT_WIDTH = 5;
static const int COUNT_BASE = 16;
- static const double COUNT_MAX = pow((double)COUNT_BASE, COUNT_WIDTH);
! if (instanceNameCount_ > COUNT_MAX)
! throw Exception("ObjectHandlerXL::generateInstanceName: max count value exceeded");
std::ostringstream s;
s << "obj_" << std::setw(COUNT_WIDTH) << std::setfill('0') << std::setbase(COUNT_BASE) << instanceNameCount_++;
--- 139,159 ----
std::string ObjectHandlerXL::generateInstanceName() {
+ /*
+ The user has provided a null string as the object ID so generate a name automatically.
+ The name is in the format obj_XXXXX where XXXXX is a hexidecimal value which is COUNT_WIDTH
+ digits long until the value exceeds COUNT_BASE^COUNT_WIDTH at which point the length grows
+ as necessary until ULONG_MAX is hit and an exception is thrown.
+ */
static const int COUNT_WIDTH = 5;
static const int COUNT_BASE = 16;
! if (instanceNameCount_ == ULONG_MAX) {
! std::ostringstream msg;
! msg << "ObjectHandler has exceeded the maximum limit of " << ULONG_MAX
! << " names that can be automatically generated for 'anonymous objects'"
! << " (objects where the user has supplied an empty string as an ID)."
! << " Please invoke ohDeleteAllObjects(TRUE) or restart the application.";
! throw Exception(msg.str());
! }
std::ostringstream s;
s << "obj_" << std::setw(COUNT_WIDTH) << std::setfill('0') << std::setbase(COUNT_BASE) << instanceNameCount_++;
***************
*** 175,180 ****
void ObjectHandlerXL::deleteAllObjects(const bool &deletePermanent) {
! if (deletePermanent)
callingRanges_.clear();
ObjectHandler::deleteAllObjects(deletePermanent);
}
--- 183,190 ----
void ObjectHandlerXL::deleteAllObjects(const bool &deletePermanent) {
! if (deletePermanent) {
callingRanges_.clear();
+ instanceNameCount_ = 0;
+ }
ObjectHandler::deleteAllObjects(deletePermanent);
}
Index: objecthandlerxl.hpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/ohxl/objecthandlerxl.hpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** objecthandlerxl.hpp 18 Jun 2006 13:41:51 -0000 1.8
--- objecthandlerxl.hpp 28 Jun 2006 14:28:32 -0000 1.9
***************
*** 72,76 ****
virtual std::string generateInstanceName();
void clearCallingRange(boost::shared_ptr < CallingRange > callingRange);
! static int instanceNameCount_;
};
--- 72,76 ----
virtual std::string generateInstanceName();
void clearCallingRange(boost::shared_ptr < CallingRange > callingRange);
! static unsigned long instanceNameCount_;
};
|