// $Revision: 1.18 $ //------------------------------------------------------------------------------ // // Copyright (C) 1994, 1995 Taligent, Inc. All rights reserved. // // Project: StockBrowser // File: PickerModel.h // Build/Version: 1.0.0 // // Description: TPickerModel holds a collection of stocks, each identified // by a unique name. // // TPickerSelection specifies zero or more stocks owned by a // TPickerModel. // //------------------------------------------------------------------------------ #ifndef TaligentSamples_PICKERMODEL #define TaligentSamples_PICKERMODEL class TPickerModel; class TPickerSelection; #ifndef TaligentSamples_STOCKDATA #include #endif #ifndef Taligent_GUICOMPOUNDDOCUMENT #include #endif //============================================================================== // TPickerModel class TPickerModel : public TModel { public: ModelDeclarationsMacro(TPickerModel); public: TPickerModel(); TPickerModel(const TPickerModel& source); virtual ~TPickerModel(); TPickerModel& operator=(const TPickerModel& source); virtual TStream& operator>>=(TStream& toStream) const; virtual TStream& operator<<=(TStream& fromStream); virtual bool operator==(const TPickerModel& other) const; virtual long Hash() const; TPseudoTimeStamp GetStockTimeStamp() const; virtual void SetStockTimeStamp(const TPseudoTimeStamp& timestamp); //.......................................................................... // TModel override virtual TModelSelection* CreateSelection() const; //.......................................................................... // To use these functions, you must acquire a write-entry for the // document component. virtual void AdoptStocks(TCollectionOf& adoptEach); virtual void AdoptStock(TStockData* adoptee); virtual TStockData* OrphanStock(const TStandardText& name); //.......................................................................... // To use these functions, you must acquire a read-entry for the // document component. virtual void CopyNames(TCollectionOf& fillWithNames) const; const TStockData* GetStock(const TStandardText& name) const; virtual void GetNames(TCollectionOf& fillWithNames) const; private: void CopyContentsFrom(const TPickerModel& source); enum {kOriginalVersion}; TDictionaryOf fStocks; TPseudoTimeStamp fStockTimeStamp; }; //============================================================================== // TPickerSelection class TPickerSelection : public TModelSelection, public MDataExchanger { public: TaligentTypeExtensionDeclarationsMacro(TPickerSelection) public: TPickerSelection(); TPickerSelection(const TPickerSelection& source); TPickerSelection(const TModelReference& theModel); virtual ~TPickerSelection(); TPickerSelection& operator=(const TPickerSelection& source); virtual TStream& operator>>=(TStream& toStream) const; virtual TStream& operator<<=(TStream& fromStream); //.......................................................................... // TModelSelection overrides virtual void DeselectAll(); virtual void SelectWholeModel(); //.......................................................................... // Public MDataExchanger overrides virtual void CreateAvailableTypesList( TSequenceOf& theTypes) const; virtual void ChooseTypes(const TSequenceOf& theChoices, TSequenceOf& theChosenTypes) const; //.......................................................................... // To use these functions, you must acquire a write-entry for the // document component. virtual void SelectStock(const TStandardText& name); virtual void DeselectStock(const TStandardText& name); virtual void ExtendTo(const TPickerSelection& other); //.......................................................................... // To use these functions, you must acquire a read-entry for the // document component. virtual void GetSelectedStocks(TCollectionOf& fill) const; virtual void GetSelectedNames(TCollectionOf& fill) const; protected: //.......................................................................... // Protected MDataExchanger overrides virtual TModel* HandleCopyData(const TTypeDescription& theType) const; virtual void HandleCopyDataInto(TModel& theModel) const; virtual TModel* HandleOrphanData(); virtual TModel* HandleReplaceData(TModel* adoptedData); virtual TPickerModel* CreateEmptyModel() const; private: void CopyContentsFrom(const TPickerSelection& source); enum {kOriginalVersion}; TArrayOf fStocks; }; #endif