home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 6.1 KB | 194 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWSUSink.h
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWSUSINK_H
- #define FWSUSINK_H
-
- #ifndef SOM_FW_OStorageUnitSink_xh
- #include "SLSUSink.xh"
- #endif
-
- #ifndef FWRANSIN_H
- #include "FWRanSin.h"
- #endif
-
- #ifndef FWFILESP_H
- #include "FWFileSp.h"
- #endif
-
- #ifndef FWFILESY_H
- #include "FWFileSy.h"
- #endif
-
- #ifndef FWFILREP_H
- #include "FWFilRep.h"
- #endif
-
- #ifndef FWFILEAC_H
- #include "FWFileAc.h"
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- //========================================================================================
- // Forward Class Declarations
- //========================================================================================
-
- class FW_OFileSink;
-
- //========================================================================================
- // CLASS FW_PStorageUnitSink
- //========================================================================================
- // Smart pointer for FW_OStorageUnitSink
- //
- // Inherited API for operator->()
- // long GetReadableBytes();
- // void Read(in void * destination, in long count);
- // long GetWritableBytes();
- // void Write(in void* source, in long count);
- //
- // long GetLength();
- // void SetLength(in long length);
- // long GetPosition();
- // void SetPosition(in long position);
- //
- // New API for operator->()
- // ODStorageUnitView GetStorageUnitView();
- //
-
- class FW_PStorageUnitSink : public FW_PRandomAccessSink
- {
- public:
- FW_PStorageUnitSink(Environment* ev, FW_OStorageUnitSink* theStorageUnitSink);
- // The sink assumes ownership of theStorageUnitSink
-
- FW_PStorageUnitSink(Environment* ev, ODStorageUnitView* storageUnitView);
- // Create a sink attached to the storage unit view.
- // The sink does not assume ownership of the view.
-
- FW_PStorageUnitSink(Environment* ev,
- ODStorageUnit* storageUnit,
- ODPropertyName propertyName,
- ODValueType valueType);
- // Create a sink attached to the given (storageUnit, propertyName, valueType).
- // The "bufferCapacity" is for buffering reads from the storage unit
-
- virtual ~FW_PStorageUnitSink();
-
- public:
- // Covariant overrides
- FW_OStorageUnitSink* GetRep() const;
- FW_OStorageUnitSink* operator->() const;
- operator FW_OStorageUnitSink*() const;
-
- FW_OStorageUnitSink* GetStorageUnitSink() const;
-
- private:
- FW_PStorageUnitSink(const FW_PStorageUnitSink&);
- FW_PStorageUnitSink& operator=(const FW_PStorageUnitSink&);
- };
-
- //----------------------------------------------------------------------------------------
- // FW_PStorageUnitSink::GetRep
- //----------------------------------------------------------------------------------------
- inline FW_OStorageUnitSink* FW_PStorageUnitSink::GetRep() const
- {
- return (FW_OStorageUnitSink*)FW_PRandomAccessSink::GetRep();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PStorageUnitSink::operator->
- //----------------------------------------------------------------------------------------
- inline FW_OStorageUnitSink* FW_PStorageUnitSink::operator->() const
- {
- return GetRep();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PStorageUnitSink::operator FW_OStorageUnitSink*
- //----------------------------------------------------------------------------------------
- inline FW_PStorageUnitSink::operator FW_OStorageUnitSink*() const
- {
- return GetRep();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PStorageUnitSink::GetStorageUnitSink
- //----------------------------------------------------------------------------------------
- inline FW_OStorageUnitSink* FW_PStorageUnitSink::GetStorageUnitSink() const
- {
- return GetRep();
- }
-
- //========================================================================================
- // class FW_PFileValueSink
- //========================================================================================
- // Use this class to simplify reading data from files dragged into parts.
- // OpenDoc *doesn't* give you the data in a storageunit; it only gives you
- // an FSSpec. This code extracts the FSSpec and creates a sink from it.
-
- class FW_PFileValueSink
- {
- public:
- FW_DECLARE_AUTO (FW_PFileValueSink)
-
- public:
- FW_PFileValueSink (Environment* ev, ODStorageUnit* storageUnit, ODPropertyName propertyName = kODPropContents);
- ~FW_PFileValueSink();
-
- FW_OFileSink* operator->() const;
- operator FW_OFileSink*() const;
-
- FW_OFileSink* GetFileSink() const;
-
- protected:
- static HFSFlavor PrivMacGetHFSFlavor(Environment* ev, ODStorageUnit* storageUnit, ODPropertyName propertyName);
-
- private:
- FW_PFileValueSink(const FW_PFileValueSink&);
- FW_PFileValueSink& operator=(const FW_PFileValueSink&);
-
- private:
- // The order if very important because the constructor relies on it
- HFSFlavor fHfsInfo;
- FW_PFileSpecification fSpecification;
- FW_CAccessPermission fPermission;
- FW_PFile fFile;
- FW_PFileSink fSink;
- };
-
- //----------------------------------------------------------------------------------------
- // FW_PFileValueSink::operator FW_OFileSink*
- //----------------------------------------------------------------------------------------
- inline FW_PFileValueSink::operator FW_OFileSink*() const
- {
- return (FW_OFileSink*)fSink.operator->();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_OFileSink::operator->
- //----------------------------------------------------------------------------------------
- inline FW_OFileSink* FW_PFileValueSink::operator->() const
- {
- return (FW_OFileSink*)fSink.operator->();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PFileValueSink::GetFileSink
- //----------------------------------------------------------------------------------------
- inline FW_OFileSink* FW_PFileValueSink::GetFileSink() const
- {
- return (FW_OFileSink*)fSink.operator->();
- }
-
-
- #endif
-