-// File: Plugin.cxx
-// Created: Thu Mar 6 15:49:00 1997
-// Author: Mister rmi
-// <rmi@frilox.paris1.matra-dtv.fr>
+// Created on: 1997-03-06
+// Created by: Mister rmi
+// Copyright (c) 1997-1999 Matra Datavision
+// Copyright (c) 1999-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 <Plugin.ixx>
-#include <Plugin_MapOfFunctions.hxx>
#include <OSD_SharedLibrary.hxx>
-#include <Resource_Manager.hxx>
+#include <Plugin.hxx>
#include <Plugin_Failure.hxx>
-
+#include <Plugin_MapOfFunctions.hxx>
+#include <Resource_Manager.hxx>
+#include <Standard_GUID.hxx>
+#include <Standard_Transient.hxx>
#include <TCollection_AsciiString.hxx>
static Standard_Character tc[1000];
//function : Load
//purpose :
//=======================================================================
-Handle(Standard_Transient) Plugin::Load(const Standard_GUID& aGUID)
+Handle(Standard_Transient) Plugin::Load (const Standard_GUID& aGUID,
+ const Standard_Boolean theVerbose)
{
aGUID.ToCString(thePluginId);
if(!PluginResource->Find(theResource.ToCString())) {
Standard_SStream aMsg; aMsg << "could not find the resource:";
- aMsg << theResource.ToCString()<< endl;
- cout << "could not find the resource:"<<theResource.ToCString()<< endl;
- Plugin_Failure::Raise(aMsg);
+ aMsg << theResource.ToCString() << endl;
+ if (theVerbose)
+ cout << "could not find the resource:" << theResource.ToCString() << endl;
+ throw Plugin_Failure(aMsg.str().c_str());
}
TCollection_AsciiString thePluginLibrary("");
-#ifndef WNT
+#ifndef _WIN32
thePluginLibrary += "lib";
#endif
thePluginLibrary += PluginResource->Value(theResource.ToCString());
-#ifdef WNT
+#ifdef _WIN32
thePluginLibrary += ".dll";
#elif defined(__APPLE__)
thePluginLibrary += ".dylib";
aMsg << PluginResource->Value(theResource.ToCString());
aMsg << "; reason:";
aMsg << error.ToCString();
- cout << "could not open: " << PluginResource->Value(theResource.ToCString())<< " ; reason: "<< error.ToCString() << endl;
- Plugin_Failure::Raise(aMsg);
+ if (theVerbose)
+ cout << "could not open: " << PluginResource->Value(theResource.ToCString())<< " ; reason: "<< error.ToCString() << endl;
+ throw Plugin_Failure(aMsg.str().c_str());
}
f = theSharedLibrary.DlSymb("PLUGINFACTORY");
if( f == NULL ) {
Standard_SStream aMsg; aMsg << "could not find the factory in:";
aMsg << PluginResource->Value(theResource.ToCString());
aMsg << error.ToCString();
- Plugin_Failure::Raise(aMsg);
+ throw Plugin_Failure(aMsg.str().c_str());
}
theMapOfFunctions.Bind(pid,f);
}
else
f = theMapOfFunctions(pid);
- Handle(Standard_Transient) (*fp) (const Standard_GUID&) = NULL;
- fp = (Handle(Standard_Transient) (*)(const Standard_GUID&)) f;
+ Standard_Transient* (*fp) (const Standard_GUID&) = NULL;
+ fp = (Standard_Transient* (*)(const Standard_GUID&)) f;
Handle(Standard_Transient) theServiceFactory = (*fp) (aGUID);
return theServiceFactory;
}
-