1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-05-11 10:44:53 +03:00
occt/src/BinMDF/BinMDF_ADriverTable.cxx
abv d5f74e42d6 0024624: Lost word in license statement in source files
License statement text corrected; compiler warnings caused by Bison 2.41 disabled for MSVC; a few other compiler warnings on 54-bit Windows eliminated by appropriate type cast
Wrong license statements corrected in several files.
Copyright and license statements added in XSD and GLSL files.
Copyright year updated in some files.
Obsolete documentation files removed from DrawResources.
2014-02-20 16:15:17 +04:00

99 lines
3.6 KiB
C++

// Created on: 2002-10-29
// Created by: Michael SAZONOV
// Copyright (c) 2002-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BinMDF_ADriverTable.ixx>
#include <Standard_NoSuchObject.hxx>
#include <BinMDF_StringIdMap.hxx>
#include <TCollection_HAsciiString.hxx>
#include <BinMDF_DataMapIteratorOfTypeADriverMap.hxx>
//=======================================================================
//function : BinMDF_ADriverTable
//purpose : Constructor
//=======================================================================
BinMDF_ADriverTable::BinMDF_ADriverTable ()
{
}
//=======================================================================
//function : AddDriver
//purpose : Adds a translation driver <theDriver>.
//=======================================================================
void BinMDF_ADriverTable::AddDriver
(const Handle(BinMDF_ADriver)& theDriver)
{
const Handle(Standard_Type)& aType = theDriver->SourceType();
myMap.Bind (aType, theDriver);
}
//=======================================================================
//function : AssignIds
//purpose : Assigns the IDs to the drivers of the given Types.
// It uses indices in the map as IDs.
// Useful in storage procedure.
//=======================================================================
void BinMDF_ADriverTable::AssignIds
(const TColStd_IndexedMapOfTransient& theTypes)
{
myMapId.Clear();
Standard_Integer i;
for (i=1; i <= theTypes.Extent(); i++) {
const Handle(Standard_Type)& aType =
Handle(Standard_Type)::DownCast (theTypes(i));
if (myMap.IsBound (aType)) {
myMapId.Bind (aType, i);
}
else {
Standard_NoSuchObject::Raise
((TCollection_AsciiString("BinMDF_ADriverTable::AssignIds : ") +
"the type " + aType->Name() + " has not been registered").ToCString());
}
}
}
//=======================================================================
//function : AssignIds
//purpose : Assigns the IDs to the drivers of the given Type Names;
// It uses indices in the sequence as IDs.
// Useful in retrieval procedure.
//=======================================================================
void BinMDF_ADriverTable::AssignIds
(const TColStd_SequenceOfAsciiString& theTypeNames)
{
myMapId.Clear();
// first prepare the data map (TypeName => TypeID) for input types
BinMDF_StringIdMap aStringIdMap;
Standard_Integer i;
for (i=1; i <= theTypeNames.Length(); i++) {
const TCollection_AsciiString& aTypeName = theTypeNames(i);
aStringIdMap.Bind (aTypeName, i);
}
// and now associate the names with the registered types
BinMDF_DataMapIteratorOfTypeADriverMap it (myMap);
for (; it.More(); it.Next()) {
const Handle(Standard_Type)& aType = it.Key();
const Handle(BinMDF_ADriver)& aDriver = it.Value();
const TCollection_AsciiString& aTypeName = aDriver->TypeName();
if (aStringIdMap.IsBound(aTypeName)) {
i = aStringIdMap(aTypeName);
myMapId.Bind (aType, i);
}
}
}