Update of /cvsroot/objecthandler/ObjectHandler/oh
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv31825/oh
Modified Files:
object.hpp objecthandler.hpp
Log Message:
fix for gcc4.1.0 - use overloaded functions instead of template specializations
Index: object.hpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/oh/object.hpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** object.hpp 26 Jul 2006 09:36:15 -0000 1.13
--- object.hpp 27 Jul 2006 09:37:35 -0000 1.14
***************
*** 36,54 ****
// get a boost shared pointer to a class derived from Object
#define OH_GET_OBJECT( NAME, ID, OBJECT_CLASS ) \
! boost::shared_ptr<OBJECT_CLASS > NAME = \
! ObjHandler::ObjectHandler::instance().retrieveObject<OBJECT_CLASS >(ID);
// get a boost shared pointer to the client library object referenced by an ObjHandler::Object
#define OH_GET_REFERENCE( NAME, ID, OBJECT_CLASS, LIBRARY_CLASS ) \
OH_GET_OBJECT(NAME ## temp, ID, OBJECT_CLASS ) \
! /*const*/ boost::shared_ptr<LIBRARY_CLASS> NAME = \
! NAME ## temp->getLibraryObject<LIBRARY_CLASS>();
// OH_GET_REFERENCE_DEFAULT - like OH_GET_REFERENCE but only attempt retrieval if id supplied
#define OH_GET_REFERENCE_DEFAULT( NAME, ID, OBJECT_CLASS, LIBRARY_CLASS ) \
! /*const*/ boost::shared_ptr<LIBRARY_CLASS> NAME; \
if (!ID.empty()) { \
OH_GET_OBJECT(NAME ## temp, ID, OBJECT_CLASS ) \
! NAME = NAME ## temp->getLibraryObject<LIBRARY_CLASS>(); \
}
--- 36,54 ----
// get a boost shared pointer to a class derived from Object
#define OH_GET_OBJECT( NAME, ID, OBJECT_CLASS ) \
! boost::shared_ptr<OBJECT_CLASS> NAME; \
! ObjHandler::ObjectHandler::instance().retrieveObject(NAME, ID);
// get a boost shared pointer to the client library object referenced by an ObjHandler::Object
#define OH_GET_REFERENCE( NAME, ID, OBJECT_CLASS, LIBRARY_CLASS ) \
OH_GET_OBJECT(NAME ## temp, ID, OBJECT_CLASS ) \
! boost::shared_ptr<LIBRARY_CLASS> NAME; \
! NAME ## temp->getLibraryObject(NAME);
// OH_GET_REFERENCE_DEFAULT - like OH_GET_REFERENCE but only attempt retrieval if id supplied
#define OH_GET_REFERENCE_DEFAULT( NAME, ID, OBJECT_CLASS, LIBRARY_CLASS ) \
! boost::shared_ptr<LIBRARY_CLASS> NAME; \
if (!ID.empty()) { \
OH_GET_OBJECT(NAME ## temp, ID, OBJECT_CLASS ) \
! NAME ## temp->getLibraryObject(NAME); \
}
***************
*** 142,151 ****
public:
template <class LibraryDerivedClass>
! /*const*/ boost::shared_ptr<LibraryDerivedClass> getLibraryObject() const {
! boost::shared_ptr<LibraryDerivedClass> ret =
! boost::dynamic_pointer_cast<LibraryDerivedClass>(libraryObject_);
! if (ret)
! return ret;
! else {
std::ostringstream msg;
msg << "Error retrieving library object - unable to convert reference"
--- 142,148 ----
public:
template <class LibraryDerivedClass>
! void getLibraryObject(boost::shared_ptr<LibraryDerivedClass> &ret) const {
! ret = boost::dynamic_pointer_cast<LibraryDerivedClass>(libraryObject_);
! if (!ret) {
std::ostringstream msg;
msg << "Error retrieving library object - unable to convert reference"
***************
*** 154,164 ****
throw Exception(msg.str());
}
-
}
! // temporarily commented out - need to fix the syntax for gcc 4.1.0
! //template <>
! ///*const*/ boost::shared_ptr<LibraryClass> getLibraryObject<LibraryClass>() const {
! // return libraryObject_;
! //}
protected:
boost::shared_ptr<LibraryClass> libraryObject_;
--- 151,158 ----
throw Exception(msg.str());
}
}
! void getLibraryObject(boost::shared_ptr<LibraryClass> &ret) const {
! ret = libraryObject_;
! }
protected:
boost::shared_ptr<LibraryClass> libraryObject_;
Index: objecthandler.hpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/oh/objecthandler.hpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** objecthandler.hpp 26 Jul 2006 09:36:15 -0000 1.10
--- objecthandler.hpp 27 Jul 2006 09:37:35 -0000 1.11
***************
*** 56,75 ****
template < typename T >
! boost::shared_ptr < T > retrieveObject(const std::string &id) {
! boost::shared_ptr < Object > object = retrieveObjectImpl(id);
! boost::shared_ptr < T > ret =
! boost::dynamic_pointer_cast < T > (object);
if (!ret)
throw Exception("Error retrieving object with id '"
+ id + "' - unable to convert reference to type '"
+ typeid(T).name() + "'");
- return ret;
}
! //template <>
! //boost::shared_ptr < Object > retrieveObject<Object>(
! // const std::string &id) {
! // return retrieveObjectImpl(id);
! //}
//! Delete Object with given instance name.
--- 56,73 ----
template < typename T >
! void retrieveObject(boost::shared_ptr<T> &ret, const std::string &id) {
! boost::shared_ptr<Object> object = retrieveObjectImpl(id);
! ret = boost::dynamic_pointer_cast<T> (object);
if (!ret)
throw Exception("Error retrieving object with id '"
+ id + "' - unable to convert reference to type '"
+ typeid(T).name() + "'");
}
! void retrieveObject(
! boost::shared_ptr<Object> &ret,
! const std::string &id) {
! ret = retrieveObjectImpl(id);
! }
//! Delete Object with given instance name.
***************
*** 114,123 ****
};
- template <>
- inline boost::shared_ptr<Object> ObjectHandler::retrieveObject<Object>(
- const std::string &id) {
- return retrieveObjectImpl(id);
- }
-
}
--- 112,115 ----
|