// $Revision: 1.29 $ //------------------------------------------------------------------------------ // // Copyright (C) 1994, 1995 Taligent, Inc. All rights reserved. // // Project: StockBrowser // File: StockServer.h // Build/Version: 1.0.0 // // Description: TStockServer retrieves data from the disk dictionary and // returns it. // // TStockServerShutdownHandler shuts down the Stock Server // cleanly when CommonPoint is shut down. // // TStockDispatcher is derived from MRemoteDispatcher and is // the "receiver" in any remote procedure call involving the // Stock Server. // //------------------------------------------------------------------------------ #ifndef TaligentSamples_STOCKSERVER #define TaligentSamples_STOCKSERVER class TStockServer; class TStockServerShutdownHandler; class TStockDispatcher; #ifndef TaligentSamples_STOCKDATABASE #include "StockDatabase.h" #endif #ifndef Taligent_REMOTEDISPATCHER #include #endif #ifndef Taligent_SHUTDOWN #include #endif class TStockData; class TStockDay; class TDirectory; template class TDiskDictionaryOf; template class TDiskDictionaryIteratorOf; //============================================================================== // TStockServer class TStockServer : public TStockDatabase { public: TaligentTypeExtensionDeclarationsMacro(TStockServer) public: typedef TDiskDictionaryOf > TServerDictionary; typedef TDiskDictionaryIteratorOf > TServerDictionaryIterator; TStockServer(); // Uses default directory and store names TStockServer( const TStandardText& dataDirectory, const TStandardText& dataFileName); virtual ~TStockServer(); virtual TStream& operator>>=(TStream& toStream) const; virtual TStream& operator<<=(TStream& fromStream); //.......................................................................... // MStockDatabase overrides virtual void CopyAvailableNames(TCollectionOf& collectionToFill); virtual void CopyAllStocks(TCollectionOf& collectionToFill); virtual TStockData* CopyStock(const TStandardText& stockName); virtual bool CopyStockData(const TStandardText& stockName, TCollectionOf& collectionToFill, const TRangeOfDays& range = TRangeOfDays::kAllDays); virtual TPseudoTimeStamp GetTimeStamp(); //.......................................................................... // AddStockData adds stock data to the disk dictionary this server // uses. Construct a server object with a different disk dictionary // to add stock data to an alternate disk dictionary. virtual void AddStockData( const TStandardText& stockName, const TDirectory& sourceFileDirectory, const TStandardText& sourceFileName); protected: TServerDictionary* GetDictionary(); TServerDictionary* CreateOrOpenDiskDictionary(); virtual TStockData* HandleCreateStock(const TStandardText& stockName); private: TStockServer(const TStockServer& source); TStockServer& operator=(const TStockServer& source); enum {kOriginalVersion}; TServerDictionary* fDiskDictionary; TStandardText fDataDirectoryName; TStandardText fDiskDictionaryName; }; //============================================================================== // TStockServerShutdownHandler class TStockServerShutdownHandler : public TShutdownHandler { public: TStockServerShutdownHandler(); virtual ~TStockServerShutdownHandler(); virtual void CompleteShutdown(); }; //============================================================================== // TStockDispatcher class TStockDispatcher : public MRemoteDispatcher { public: TaligentTypeExtensionDeclarationsMacro(TStockDispatcher) public: static const TStandardText& kServiceName; static void LaunchStockServer( const TQualityOfService& networkOrSameHost); TStockDispatcher(TStockDatabase* implementation); virtual ~TStockDispatcher(); virtual TStream& operator>>=(TStream& toStream) const; virtual TStream& operator<<=(TStream& fromStream); enum EStockDispatcherRequest { kCopyAvailableNames, kCopyAllStocks, kCopyStock, kCopyStockData, kGetTimeStamp, kLastRequest = kGetTimeStamp }; protected: TStockDispatcher(); void CopyAvailableNamesStub(TStream& argStream, TStream& resultStream); void CopyAllStocksStub(TStream& argStream, TStream& resultStream); void CopyStockStub(TStream& argStream, TStream& resultStream); void CopyStockDataStub(TStream& argStream, TStream& resultStream); void GetTimeStampStub(TStream& argStream, TStream& resultStream); private: TStockDispatcher(const TStockDispatcher& source); TStockDispatcher& operator=(const TStockDispatcher& source); enum {kOriginalVersion}; TStockDatabase* fImplementation; }; #endif