diff options
author | Marc Laukien <marc@zeroc.com> | 2001-09-15 04:53:00 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2001-09-15 04:53:00 +0000 |
commit | 5570d5f046301e032bb7a83168eb264161b7a219 (patch) | |
tree | 600a21dfec9bbb259ca2d48ea62a4fc1962388d8 /cpp | |
parent | fixes (diff) | |
download | ice-5570d5f046301e032bb7a83168eb264161b7a219.tar.bz2 ice-5570d5f046301e032bb7a83168eb264161b7a219.tar.xz ice-5570d5f046301e032bb7a83168eb264161b7a219.zip |
more Freeze stuff
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/include/Freeze/Initialize.h | 13 | ||||
-rw-r--r-- | cpp/slice/Freeze/DB.ice | 18 | ||||
-rw-r--r-- | cpp/src/Freeze/DBI.cpp | 72 | ||||
-rw-r--r-- | cpp/src/Freeze/DBI.h | 43 | ||||
-rw-r--r-- | cpp/src/Freeze/Makefile | 3 |
5 files changed, 128 insertions, 21 deletions
diff --git a/cpp/include/Freeze/Initialize.h b/cpp/include/Freeze/Initialize.h index 142cb55e9b7..5f0caf8325e 100644 --- a/cpp/include/Freeze/Initialize.h +++ b/cpp/include/Freeze/Initialize.h @@ -12,23 +12,24 @@ #define FREEZE_INITIALIZE_H #include <Ice/CommunicatorF.h> +#include <Ice/PropertiesF.h> #include <Freeze/DBF.h> #ifdef WIN32 -# ifdef SLICE_API_EXPORTS -# define SLICE_API __declspec(dllexport) +# ifdef FREEZE_API_EXPORTS +# define FREEZE_API __declspec(dllexport) # else -# define SLICE_API __declspec(dllimport) +# define FREEZE_API __declspec(dllimport) # endif #else -# define SLICE_API /**/ +# define FREEZE_API /**/ #endif namespace Freeze { -FREEZE_API DBFactoryPtr initialize(int&, char*[], const CommunicatorPtr&); -FREEZE_API DBFactoryPtr initializeWithProperties(const PropertiesPtr&, const CommunicatorPtr&); +FREEZE_API DBFactoryPtr initialize(const ::Ice::CommunicatorPtr&); +FREEZE_API DBFactoryPtr initializeWithProperties(const ::Ice::CommunicatorPtr&, const ::Ice::PropertiesPtr&); } diff --git a/cpp/slice/Freeze/DB.ice b/cpp/slice/Freeze/DB.ice index 4676e0adff1..b89ee81a3b7 100644 --- a/cpp/slice/Freeze/DB.ice +++ b/cpp/slice/Freeze/DB.ice @@ -31,10 +31,12 @@ local class Exception { /** * - * A message describing the failure that caused the exception. + * Get a message describing the failure that caused the exception. + * + * @return The message describing the exception. * **/ - string _msg; + string message(); }; /** @@ -47,12 +49,6 @@ local class Exception **/ local class DBException extends Exception { - /** - * - * The database object that raised this exception. - * - **/ - DB _factory; }; /** @@ -99,12 +95,6 @@ local class DB **/ local class DBFactoryException extends Exception { - /** - * - * The database object factory that raised this exception. - * - **/ - DBFactory _factory; }; /** diff --git a/cpp/src/Freeze/DBI.cpp b/cpp/src/Freeze/DBI.cpp new file mode 100644 index 00000000000..1874803d7fd --- /dev/null +++ b/cpp/src/Freeze/DBI.cpp @@ -0,0 +1,72 @@ +// ********************************************************************** +// +// Copyright (c) 2001 +// MutableRealms, Inc. +// Huntsville, AL, USA +// +// All Rights Reserved +// +// ********************************************************************** + +#include <Ice/Communicator.h> +#include <Ice/Properties.h> +#include <Ice/Logger.h> +#include <Ice/LocalException.h> +#include <Freeze/DBI.h> + +using namespace std; +using namespace Ice; +using namespace Freeze; + +DBPtr +Freeze::DBFactoryI::createDB() +{ + JTCSyncT<JTCMutex> sync(*this); + + if (_destroy) + { + throw ObjectNotExistException(__FILE__, __LINE__); + } + + return 0; +} + +void +Freeze::DBFactoryI::destroy() +{ + JTCSyncT<JTCMutex> sync(*this); + + if (_destroy) + { + throw ObjectNotExistException(__FILE__, __LINE__); + } + + _destroy = true; +} + +Freeze::DBFactoryI::DBFactoryI(const CommunicatorPtr& communicator, const PropertiesPtr& properties) : + _communicator(communicator), + _properties(properties), + _destroy(false) +{ +} + +Freeze::DBFactoryI::~DBFactoryI() +{ + if (!_destroy) + { + _communicator->getLogger()->warning("database factory object has not been destroyed"); + } +} + +DBFactoryPtr +Freeze::initialize(const CommunicatorPtr& communicator) +{ + return new DBFactoryI(communicator, communicator->getProperties()); +} + +DBFactoryPtr +Freeze::initializeWithProperties(const CommunicatorPtr& communicator, const PropertiesPtr& properties) +{ + return new DBFactoryI(communicator, properties); +} diff --git a/cpp/src/Freeze/DBI.h b/cpp/src/Freeze/DBI.h new file mode 100644 index 00000000000..2c8c7f7ec3e --- /dev/null +++ b/cpp/src/Freeze/DBI.h @@ -0,0 +1,43 @@ +// ********************************************************************** +// +// Copyright (c) 2001 +// MutableRealms, Inc. +// Huntsville, AL, USA +// +// All Rights Reserved +// +// ********************************************************************** + +#ifndef FREEZE_DB_FACTORY_I_H +#define FREEZE_DB_FACTORY_I_H + +#include <Freeze/Initialize.h> +#include <Freeze/DB.h> + +namespace Freeze +{ + +class DBFactoryI : public DBFactory, public JTCMutex +{ +public: + + virtual DBPtr createDB(); + virtual void destroy(); + +private: + + DBFactoryI(const ::Ice::CommunicatorPtr&, const ::Ice::PropertiesPtr&); + virtual ~DBFactoryI(); + + friend FREEZE_API DBFactoryPtr initialize(const ::Ice::CommunicatorPtr&); + friend FREEZE_API DBFactoryPtr initializeWithProperties(const ::Ice::CommunicatorPtr&, + const ::Ice::PropertiesPtr&); + + ::Ice::CommunicatorPtr _communicator; + ::Ice::PropertiesPtr _properties; + bool _destroy; +}; + +} + +#endif diff --git a/cpp/src/Freeze/Makefile b/cpp/src/Freeze/Makefile index 8bdd14d853b..cfec4712aed 100644 --- a/cpp/src/Freeze/Makefile +++ b/cpp/src/Freeze/Makefile @@ -18,7 +18,8 @@ VERSIONED_NAME = $(top_srcdir)/lib/$(VERSIONED_BASE) TARGETS = $(NAME) $(VERSIONED_NAME) -OBJS = DB.o +OBJS = DB.o \ + DBI.o SRCS = $(OBJS:.o=.cpp) |