home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 4.0 KB | 96 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWLocMap.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFound.hpp"
-
- #ifndef FWARDYNA_H
- #include "FWArDyna.h"
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // Any DLL that declares dynamically archivable classes must have its own local copies
- // of two FW_CDynamicArchiver maps. This .cpp file declares storage for these local maps.
- // The compile output (.obj) of this file must be *statically* linked into *each* DLL
- // that declares archivable classes.
- //========================================================================================
-
-
- //----------------------------------------------------------------------------------------
- // FW_CDynamicArchiver Local maps
- //
- // These maps cannot be a static objects, because we must guarantee
- // that they are initialized before any FW_CDynamicArchiver is initialized.
- // We achieve this by using the accessor functions below. The first time the
- // accessor function is called, the corresponding data structure is initialized.
- //
- //----------------------------------------------------------------------------------------
-
- FW_CPrivNameToLabelMap * FW_CDynamicArchiver::gLocalClassNameToClassLabelMap = 0;
- FW_CPrivLabelToIOFunctionMap * FW_CDynamicArchiver::gLocalClassLabelToObjectIOFunctionMap = 0;
-
- //----------------------------------------------------------------------------------------
- // FW_PrivGetLocalNameToLabelMap
- //----------------------------------------------------------------------------------------
-
- FW_ARCHIVE_FUNC_ATTR FW_CPrivNameToLabelMap& FW_PrivGetLocalNameToLabelMap()
- {
- if (FW_CDynamicArchiver::gLocalClassNameToClassLabelMap == 0)
- {
- FW_CDynamicArchiver::gLocalClassNameToClassLabelMap = new FW_CPrivNameToLabelMap();
- }
- return *FW_CDynamicArchiver::gLocalClassNameToClassLabelMap;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PrivGetLocalLabelToIOFunctionMap
- //----------------------------------------------------------------------------------------
-
- FW_ARCHIVE_FUNC_ATTR FW_CPrivLabelToIOFunctionMap& FW_PrivGetLocalLabelToIOFunctionMap()
- {
- if (FW_CDynamicArchiver::gLocalClassLabelToObjectIOFunctionMap == 0)
- {
- FW_CDynamicArchiver::gLocalClassLabelToObjectIOFunctionMap = new FW_CPrivLabelToIOFunctionMap();
- }
- return *FW_CDynamicArchiver::gLocalClassLabelToObjectIOFunctionMap;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_MergeArchiverMaps
- //
- // This function will work if and only if it is statically linked into *each*
- // DLL that has archivable class infos. Each copy of this function must be
- // called during application initialization (before any objects are read from
- // or written to an archive. Since all copies have the same name, the DLL
- // developer must provide a uniquely named function that calls this function,
- // and then arrange for that function to be statically linked to this function.
- // The application developer can then call the uniquely named, DLL-specific function.
- // Note that for safety, this function should not be exported if the build
- // environment supports that feature.
- //
- //----------------------------------------------------------------------------------------
-
- void FW_ARCHIVE_FUNC_ATTR FW_MergeArchiverMaps()
- {
- FW_CDynamicArchiver::MergeNameToLabelMaps(FW_PrivGetLocalNameToLabelMap(),
- FW_CDynamicArchiver::GetNameToLabelMap());
- FW_CDynamicArchiver::MergeLabelToIOFunctionMaps(FW_PrivGetLocalLabelToIOFunctionMap(),
- FW_CDynamicArchiver::GetLabelToIOFunctionMap());
- }
-
- #ifdef FW_BUILD_WIN16
- extern "C" void FW_FUNC_ATTR FW_MERGEARCHIVERMAPSHOOK()
- {
- FW_MergeArchiverMaps();
- }
- #endif
-