// // Copyright (c) ZeroC, Inc. All rights reserved. // #ifndef ICEGRID_SESSIONI_H #define ICEGRID_SESSIONI_H #include #include #include #include #include namespace IceGrid { class Allocatable; class AllocationRequest; class Database; class SessionI; class TraceLevels; class BaseSessionI : public virtual Ice::Object, public std::enable_shared_from_this { public: virtual ~BaseSessionI() = default; virtual void keepAlive(const Ice::Current&); std::chrono::steady_clock::time_point timestamp() const; void shutdown(); std::shared_ptr getGlacier2IdentitySet(); std::shared_ptr getGlacier2AdapterIdSet(); const std::string& getId() const { return _id; } virtual void destroyImpl(bool); protected: BaseSessionI(const std::string&, const std::string&, const std::shared_ptr&); const std::string _id; const std::string _prefix; const std::shared_ptr _traceLevels; const std::shared_ptr _database; std::shared_ptr _servantManager; bool _destroyed; std::chrono::steady_clock::time_point _timestamp; mutable std::mutex _mutex; }; struct SessionDestroyedException { }; class SessionI final : public BaseSessionI, public Session { public: SessionI(const std::string&, const std::shared_ptr&, const IceUtil::TimerPtr&); std::shared_ptr _register(const std::shared_ptr&, const std::shared_ptr&); void keepAlive(const Ice::Current& current) override { BaseSessionI::keepAlive(current); } void allocateObjectByIdAsync(Ice::Identity id, std::function& returnValue)> response, std::function exception, const Ice::Current& current) override; void allocateObjectByTypeAsync(std::string, std::function& returnValue)> response, std::function exception, const Ice::Current& current) override; void releaseObject(Ice::Identity, const Ice::Current&) override; void setAllocationTimeout(int, const Ice::Current&) override; void destroy(const Ice::Current&) override; int getAllocationTimeout() const; const IceUtil::TimerPtr& getTimer() const { return _timer; } bool addAllocationRequest(const std::shared_ptr&); void removeAllocationRequest(const std::shared_ptr&); void addAllocation(const std::shared_ptr&); void removeAllocation(const std::shared_ptr&); protected: void destroyImpl(bool) override; const IceUtil::TimerPtr _timer; int _allocationTimeout; std::set> _requests; std::set> _allocations; }; class ClientSessionFactory final { public: ClientSessionFactory(const std::shared_ptr&, const std::shared_ptr&, const IceUtil::TimerPtr&, const std::shared_ptr&); std::shared_ptr createGlacier2Session(const std::string&, const std::shared_ptr&); std::shared_ptr createSessionServant(const std::string&, const std::shared_ptr&); const std::shared_ptr& getTraceLevels() const; private: const std::shared_ptr _servantManager; const std::shared_ptr _database; const IceUtil::TimerPtr _timer; const std::shared_ptr _reaper; const bool _filters; }; class ClientSessionManagerI final : public Glacier2::SessionManager { public: ClientSessionManagerI(const std::shared_ptr&); std::shared_ptr create(std::string, std::shared_ptr, const Ice::Current&) override; private: const std::shared_ptr _factory; }; class ClientSSLSessionManagerI final : public Glacier2::SSLSessionManager { public: ClientSSLSessionManagerI(const std::shared_ptr&); std::shared_ptr create(Glacier2::SSLInfo, std::shared_ptr, const Ice::Current&) override; private: const std::shared_ptr _factory; }; }; #endif