-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "HELLO.hxx"
#include "HELLO_version.h"
+#include <SALOME_KernelServices.hxx>
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(SALOMEDS)
#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
return fullName;
}
}
-
/*!
\brief Constructor
\param instanceName SALOME component instance name
\param interfaceName SALOME component interface name
*/
-HELLO::HELLO( CORBA::ORB_ptr orb,
+HELLO_Abstract::HELLO_Abstract( CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
PortableServer::ObjectId* contId,
const char* instanceName,
- const char* interfaceName )
- : Engines_Component_i( orb, poa, contId, instanceName, interfaceName )
+ const char* interfaceName,
+ bool withRegistry)
+ : Engines_Component_i( orb, poa, contId, instanceName, interfaceName, false, withRegistry)
{
_thisObj = this;
_id = _poa->activate_object( _thisObj ); // register and activate this servant object
Clean up allocated resources
*/
-HELLO::~HELLO()
+HELLO_Abstract::~HELLO_Abstract()
{
// nothing to do
}
/*!
\brief Say hello to \a name
- \param study SALOME study
\param name person's name
\return operation status
*/
-HELLO_ORB::status HELLO::hello( SALOMEDS::Study_ptr study, const char* name )
+HELLO_ORB::status HELLO_Abstract::hello( const char* name )
{
// set exception handler to catch unexpected CORBA exceptions
Unexpect aCatch(SALOME_SalomeException);
// set result status to error initially
HELLO_ORB::status result = HELLO_ORB::OP_ERR_UNKNOWN;
+ SALOMEDS::Study_var aStudy = this->getStudyServant();
// check if reference to study is valid
- if ( !CORBA::is_nil( study ) ) {
+ if ( !CORBA::is_nil( aStudy ) ) {
// get full object path
std::string fullName = studyName( name );
// check if the object with the same name is already registered in the study
- SALOMEDS::SObject_var sobj = study->FindObjectByPath( fullName.c_str() );
+ SALOMEDS::SObject_var sobj = aStudy->FindObjectByPath( fullName.c_str() );
if ( !CORBA::is_nil( sobj ) ) {
// person is already registered in the study -> ERROR
result = HELLO_ORB::OP_ERR_ALREADY_MET;
}
else {
// person is not registered yet -> register
- SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder(); // study builder
- SALOMEDS::UseCaseBuilder_var useCaseBuilder = study->GetUseCaseBuilder(); // use case builder
+ SALOMEDS::StudyBuilder_var studyBuilder = aStudy->NewBuilder(); // study builder
+ SALOMEDS::UseCaseBuilder_var useCaseBuilder = aStudy->GetUseCaseBuilder(); // use case builder
// find HELLO component; create it if not found
- SALOMEDS::SComponent_var father = study->FindComponent( "HELLO" );
+ SALOMEDS::SComponent_var father = aStudy->FindComponent( "HELLO" );
if ( CORBA::is_nil( father ) ) {
// create component
father = studyBuilder->NewComponent( "HELLO" );
/*!
\brief Say goodbye to \a name
- \param study SALOME study
\param name person's name
\return operation status
*/
-HELLO_ORB::status HELLO::goodbye( SALOMEDS::Study_ptr study, const char* name )
+HELLO_ORB::status HELLO_Abstract::goodbye( const char* name )
{
// set exception handler to catch unexpected CORBA exceptions
Unexpect aCatch(SALOME_SalomeException);
// set result status to error initially
HELLO_ORB::status result = HELLO_ORB::OP_ERR_UNKNOWN;
+ SALOMEDS::Study_var aStudy = this->getStudyServant();
// check if reference to study is valid
- if ( !CORBA::is_nil( study ) ) {
+ if ( !CORBA::is_nil( aStudy ) ) {
// get full object path
std::string fullName = studyName( name );
// check if the object with the same name is registered in the study
// find all objects with same name
- SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder(); // study builder
- SALOMEDS::UseCaseBuilder_var useCaseBuilder = study->GetUseCaseBuilder(); // use case builder
- SALOMEDS::SObject_var sobj = study->FindObjectByPath( fullName.c_str() );
+ SALOMEDS::StudyBuilder_var studyBuilder = aStudy->NewBuilder(); // study builder
+ SALOMEDS::UseCaseBuilder_var useCaseBuilder = aStudy->GetUseCaseBuilder(); // use case builder
+ SALOMEDS::SObject_var sobj = aStudy->FindObjectByPath( fullName.c_str() );
while ( !CORBA::is_nil( sobj ) ) {
std::list<SALOMEDS::SObject_var> toRemove;
toRemove.push_back( sobj );
// set operation status to OK as at least one object is removed
result = HELLO_ORB::OP_OK;
}
- sobj = study->FindObjectByPath( fullName.c_str() );
+ sobj = aStudy->FindObjectByPath( fullName.c_str() );
}
}
\param row position in the parent object's children list at which objects are copied/moved
\param isCopy \c true if object are copied or \c false otherwise
*/
-void HELLO::copyOrMove( const HELLO_ORB::object_list& what,
+void HELLO_Abstract::copyOrMove( const HELLO_ORB::object_list& what,
SALOMEDS::SObject_ptr where,
CORBA::Long row, CORBA::Boolean isCopy )
{
if ( CORBA::is_nil( where ) ) return; // bad parent
- SALOMEDS::Study_var study = where->GetStudy(); // study
- SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder(); // study builder
- SALOMEDS::UseCaseBuilder_var useCaseBuilder = study->GetUseCaseBuilder(); // use case builder
+ SALOMEDS::Study_var aStudy = this->getStudyServant();
+ SALOMEDS::StudyBuilder_var studyBuilder = aStudy->NewBuilder(); // study builder
+ SALOMEDS::UseCaseBuilder_var useCaseBuilder = aStudy->GetUseCaseBuilder(); // use case builder
SALOMEDS::SComponent_var father = where->GetFatherComponent(); // father component
std::string dataType = father->ComponentDataType();
if ( dataType != "HELLO" ) return; // not a HELLO component
}
// Version information
-char* HELLO::getVersion()
+char* HELLO_Abstract::getVersion()
{
-#if HELLO_DEVELOPMENT
+#if defined(HELLO_DEVELOPMENT)
return CORBA::string_dup(HELLO_VERSION_STR"dev");
#else
return CORBA::string_dup(HELLO_VERSION_STR);
#endif
}
+SALOMEDS::Study_var HELLO_Session::getStudyServant()
+{
+ return KERNEL::getStudyServant();
+}
+
+#include "SALOMEDS_Study_i.hxx"
+
+SALOMEDS::Study_var HELLO_No_Session::getStudyServant()
+{
+ return SALOMEDS::Study::_duplicate(KERNEL::getStudyServantSA());
+}
+
extern "C"
{
/*!
const char* instanceName,
const char* interfaceName )
{
- HELLO* component = new HELLO( orb, poa, contId, instanceName, interfaceName );
+ HELLO_Session* component = new HELLO_Session( orb, poa, contId, instanceName, interfaceName );
return component->getId();
}
}