Update of /cvsroot/objecthandler/ObjectHandler/ohxl
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv29781/ohxl
Modified Files:
objecthandlerxl.cpp objecthandlerxl.hpp
Log Message:
cleaner processing for object references
Index: objecthandlerxl.cpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/ohxl/objecthandlerxl.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** objecthandlerxl.cpp 2 Jun 2006 13:59:05 -0000 1.4
--- objecthandlerxl.cpp 9 Jun 2006 18:58:27 -0000 1.5
***************
*** 38,41 ****
--- 38,56 ----
int ObjectHandlerXL::instanceNameCount_ = 0;
+ // std::map cannot be exported across DLL boundaries
+ // so instead we use a static variable
+ std::map < std::string, boost::shared_ptr < CallingRange > > callingRanges_;
+
+ ObjectHandlerXL &ObjectHandlerXL::instance() {
+ if (instance_) {
+ ObjectHandlerXL *ret = dynamic_cast < ObjectHandlerXL* > (instance_);
+ if (ret)
+ return *ret;
+ else
+ throw std::exception("Attempt to reference uninitialized ObjectHandlerXL object");
+ } else
+ throw std::exception("Attempt to reference uninitialized ObjectHandlerXL object");
+ }
+
boost::shared_ptr < CallingRange > ObjectHandlerXL::getCallingRange() {
***************
*** 93,97 ****
std::string ObjectHandlerXL::storeObject(
const std::string &instanceName,
! const obj_ptr &object) {
boost::shared_ptr < CallingRange > callingRange = getCallingRange();
--- 108,112 ----
std::string ObjectHandlerXL::storeObject(
const std::string &instanceName,
! const boost::shared_ptr < Object > &object) {
boost::shared_ptr < CallingRange > callingRange = getCallingRange();
***************
*** 107,125 ****
instanceNameDerived = instanceName;
! ObjectList::const_iterator i = objectList_.find(instanceNameDerived);
! if (i != objectList_.end()) {
! std::ostringstream msg;
! msg << "unable to instantiate object with instance name '" << instanceNameDerived
! << "' because another object with that instance name already exists.";
! throw Exception(msg.str());
! }
callingRange->registerObject(instanceNameDerived);
! std::string instanceNameCounter = ObjectHandlerBase::storeObject(instanceNameDerived, object);
return instanceNameCounter + "#" + callingRange->updateCount();
}
! obj_ptr ObjectHandlerXL::retrieveObject(const std::string &instanceName) const {
std::string instanceNameStub;
int counterOffset = instanceName.length() - 5;
--- 122,134 ----
instanceNameDerived = instanceName;
! checkName(instanceNameDerived);
callingRange->registerObject(instanceNameDerived);
! std::string instanceNameCounter = ObjectHandler::storeObject(instanceNameDerived, object);
return instanceNameCounter + "#" + callingRange->updateCount();
}
! boost::shared_ptr < Object > ObjectHandlerXL::retrieveObjectImpl(const std::string &instanceName) const {
std::string instanceNameStub;
int counterOffset = instanceName.length() - 5;
***************
*** 128,132 ****
else
instanceNameStub = instanceName;
! return ObjectHandlerBase::retrieveObject(instanceNameStub);
}
--- 137,141 ----
else
instanceNameStub = instanceName;
! return ObjectHandler::retrieveObjectImpl(instanceNameStub);
}
***************
*** 160,168 ****
void ObjectHandlerXL::deleteAllObjects() {
callingRanges_.clear();
! ObjectHandlerBase::deleteAllObjects();
}
void ObjectHandlerXL::dump(std::ostream& out) {
! ObjectHandlerBase::dump(out);
out << std::endl << "calling ranges:";
--- 169,177 ----
void ObjectHandlerXL::deleteAllObjects() {
callingRanges_.clear();
! ObjectHandler::deleteAllObjects();
}
void ObjectHandlerXL::dump(std::ostream& out) {
! ObjectHandler::dump(out);
out << std::endl << "calling ranges:";
Index: objecthandlerxl.hpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/ohxl/objecthandlerxl.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** objecthandlerxl.hpp 2 Jun 2006 13:59:05 -0000 1.4
--- objecthandlerxl.hpp 9 Jun 2006 18:58:27 -0000 1.5
***************
*** 23,27 ****
#define ohxl_objecthandlerxl_hpp
! #include <oh/objecthandlerbase.hpp>
//! ObjHandler
--- 23,27 ----
#define ohxl_objecthandlerxl_hpp
! #include <oh/objecthandler.hpp>
//! ObjHandler
***************
*** 29,32 ****
--- 29,33 ----
*/
namespace ObjHandler {
+
class CallingRange;
***************
*** 36,41 ****
by the client application.
*/
! class ObjectHandlerXL : public ObjectHandlerBase {
public:
//! Store Object with given instance name.
/*! This function is optimized for the base case where the calling range
--- 37,44 ----
by the client application.
*/
! class DLL_API ObjectHandlerXL : public ObjectHandler {
public:
+ static ObjectHandlerXL &instance();
+
//! Store Object with given instance name.
/*! This function is optimized for the base case where the calling range
***************
*** 52,59 ****
*/
virtual std::string storeObject(const std::string &instanceName,
! const obj_ptr &object);
! virtual obj_ptr retrieveObject(const std::string &instanceName) const;
virtual void collectGarbage();
virtual void deleteAllObjects();
//! Reset the calling cell.
/*! This function resets the status of the calling cell to "not busy" and
--- 55,63 ----
*/
virtual std::string storeObject(const std::string &instanceName,
! const boost::shared_ptr < Object > &object);
! virtual boost::shared_ptr < Object > retrieveObjectImpl(const std::string &instanceName) const;
virtual void collectGarbage();
virtual void deleteAllObjects();
+
//! Reset the calling cell.
/*! This function resets the status of the calling cell to "not busy" and
***************
*** 62,68 ****
*/
virtual void resetCaller();
virtual void dump(std::ostream&);
private:
- std::map < std::string, boost::shared_ptr < CallingRange > > callingRanges_;
boost::shared_ptr < CallingRange > getCallingRange();
virtual std::string generateInstanceName();
--- 66,72 ----
*/
virtual void resetCaller();
+
virtual void dump(std::ostream&);
private:
boost::shared_ptr < CallingRange > getCallingRange();
virtual std::string generateInstanceName();
|