SALOMEDSClient_SObject* aSO = NULL;
if (_isLocal) {
SALOMEDS::Locker lock;
- aSO = new SALOMEDS_SObject(_local_impl->CreateObjectID((char*)anObjectID.c_str()));
+ Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->CreateObjectID((char*)anObjectID.c_str());
+ if(aSO_impl.IsNull()) return _PTR(SObject)(aSO);
+ aSO = new SALOMEDS_SObject(aSO_impl);
+ }
+ else {
+ SALOMEDS::SObject_var aSO_impl = _corba_impl->CreateObjectID((char*)anObjectID.c_str());
+ if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
+ aSO = new SALOMEDS_SObject(aSO_impl);
}
- else aSO = new SALOMEDS_SObject(_corba_impl->CreateObjectID((char*)anObjectID.c_str()));
return _PTR(SObject)(aSO);
}
std::string SALOMEDS_Study::GetObjectPath(const _PTR(SObject)& theSO)
{
+ if(!theSO) return "";
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
std::string aPath;
if (_isLocal) {
#include "SALOMEDSImpl_GenericAttribute.hxx"
#include <string>
+#include <stdexcept>
#include <TCollection_AsciiString.hxx>
#include <TDF_Attribute.hxx>
void SALOMEDS_StudyBuilder::DefineComponentInstance (const _PTR(SComponent)& theSCO,
const std::string& ComponentIOR)
{
+ if(theSCO) return;
+
SALOMEDS_SComponent* aSCO = dynamic_cast<SALOMEDS_SComponent*>(theSCO.get());
if (_isLocal) {
CheckLocked();
void SALOMEDS_StudyBuilder::RemoveComponent(const _PTR(SComponent)& theSCO)
{
+ if(!theSCO) return;
SALOMEDS_SComponent* aSCO = dynamic_cast<SALOMEDS_SComponent*>(theSCO.get());
if (_isLocal) {
CheckLocked();
void SALOMEDS_StudyBuilder::LoadWith(const _PTR(SComponent)& theSCO, const std::string& theIOR)
{
+ if(!theSCO) return;
+
SALOMEDS_SComponent* aSCO = dynamic_cast<SALOMEDS_SComponent*>(theSCO.get());
CORBA::Object_var obj = _orb->string_to_object(theIOR.c_str());
SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(obj);
void SALOMEDS_StudyBuilder::RemoveObject(const _PTR(SObject)& theSO)
{
+ if(!theSO) return;
+
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
if (_isLocal) {
CheckLocked();
void SALOMEDS_StudyBuilder::RemoveObjectWithChildren(const _PTR(SObject)& theSO)
{
+ if(!theSO) return;
+
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
if (_isLocal) {
CheckLocked();
_PTR(GenericAttribute) SALOMEDS_StudyBuilder::FindOrCreateAttribute(const _PTR(SObject)& theSO,
const std::string& aTypeOfAttribute)
-{
- SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
+{
SALOMEDSClient_GenericAttribute* anAttr = NULL;
+ if(!theSO) return _PTR(GenericAttribute)(anAttr);
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
if (_isLocal) {
SALOMEDS::Locker lock;
const std::string& aTypeOfAttribute)
{
bool ret;
+
+ if(!theSO) return false;
+
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
if (_isLocal) {
SALOMEDS::Locker lock;
void SALOMEDS_StudyBuilder::RemoveAttribute(const _PTR(SObject)& theSO, const std::string& aTypeOfAttribute)
{
+ if(!theSO) return;
+
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
if (_isLocal) {
CheckLocked();
void SALOMEDS_StudyBuilder::Addreference(const _PTR(SObject)& me, const _PTR(SObject)& thereferencedObject)
{
+ if(!me || !thereferencedObject) return;
+
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(me.get());
SALOMEDS_SObject* aRefSO = dynamic_cast<SALOMEDS_SObject*>(thereferencedObject.get());
if (_isLocal) {
void SALOMEDS_StudyBuilder::RemoveReference(const _PTR(SObject)& me)
{
+ if(!me) return;
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(me.get());
if (_isLocal) {
CheckLocked();
void SALOMEDS_StudyBuilder::SetGUID(const _PTR(SObject)& theSO, const std::string& theGUID)
{
+ if(!theSO) return;
+ if(!Standard_GUID::CheckGUIDFormat((char*)theGUID.c_str())) throw invalid_argument("Invalid GUID");
+
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
if (_isLocal) {
CheckLocked();
bool SALOMEDS_StudyBuilder::IsGUID(const _PTR(SObject)& theSO, const std::string& theGUID)
{
+ if(!theSO || !Standard_GUID::CheckGUIDFormat((char*)theGUID.c_str())) return false;
+
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
bool ret;
if (_isLocal) {
void SALOMEDS_StudyBuilder::SetName(const _PTR(SObject)& theSO, const std::string& theValue)
{
+ if(!theSO) return;
+
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
if (_isLocal) {
CheckLocked();
void SALOMEDS_StudyBuilder::SetComment(const _PTR(SObject)& theSO, const std::string& theValue)
{
+ if(!theSO) return;
+
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
if (_isLocal) {
CheckLocked();
void SALOMEDS_StudyBuilder::SetIOR(const _PTR(SObject)& theSO, const std::string& theValue)
{
+ if(!theSO) return;
+
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
if (_isLocal) {
CheckLocked();