SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
SET(${PROJECT_NAME_UC}_VERSION
${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
-SET(${PROJECT_NAME_UC}_VERSION_DEV 0)
+SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
# Common CMake macros
# ===================
# test HELLO module
print("Say hello to John: should be OK")
-if hello.hello(salome.myStudy, "John") != HELLO_ORB.OP_OK:
+if hello.hello("John") != HELLO_ORB.OP_OK:
print("ERROR: wrong operation code is returned")
else:
print("OK")
print("Say hello to John: should answer 'already met'")
-if hello.hello(salome.myStudy, "John") != HELLO_ORB.OP_ERR_ALREADY_MET:
+if hello.hello("John") != HELLO_ORB.OP_ERR_ALREADY_MET:
print("ERROR: wrong operation code is returned")
else:
print("OK")
print("Say goodbye to Margaret: should answer 'did not meet yet'")
-if hello.goodbye(salome.myStudy, "Margaret") != HELLO_ORB.OP_ERR_DID_NOT_MEET:
+if hello.goodbye("Margaret") != HELLO_ORB.OP_ERR_DID_NOT_MEET:
print("ERROR: wrong operation code is returned")
else:
print("OK")
print("Say hello to John: should be OK")
-if hello.goodbye(salome.myStudy, "John") != HELLO_ORB.OP_OK:
+if hello.goodbye("John") != HELLO_ORB.OP_OK:
print("ERROR: wrong operation code is returned")
else:
print("OK")
print("Say hello to John: should answer 'did not meet yet'")
-if hello.goodbye(salome.myStudy, "John") != HELLO_ORB.OP_ERR_DID_NOT_MEET:
+if hello.goodbye("John") != HELLO_ORB.OP_ERR_DID_NOT_MEET:
print("ERROR: wrong operation code is returned")
else:
print("OK")
development is very simple. The module contains a single
component and this component provides several services called \b
hello and \b goodbye.
-Each of these functions accepts a reference to the SALOME study and
+Each of these functions accepts
a character string as the arguments and returns the status of the operation.
The component also provides a simple GUI.
that are defined in the IDL interface \a HELLO_ORB::HELLO_Gen.
\code
-HELLO_ORB::status HELLO::hello( SALOMEDS::Study_ptr study, const char* name )
+HELLO_ORB::status HELLO::hello( const char* name )
{
...
}
-HELLO_ORB::status HELLO::goodbye( SALOMEDS::Study_ptr study, const char* name )
+HELLO_ORB::status HELLO::goodbye( const char* name )
{
...
}
\code
void HELLOGUI::hello()
{
- SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
- _PTR(Study) studyDS = study->studyDS();
-
// request user name
bool ok;
QString name = QInputDialog::getText( getApp()->desktop(), tr( "QUE_HELLO_TITLE" ), tr( "QUE_ENTER_NAME" ),
if ( ok && !name.trimmed().isEmpty() ) {
// say hello to SALOME
- HELLO_ORB::status status = engine()->hello( _CAST(Study, studyDS)->GetStudy(), (const char*)name.toLatin1() );
+ HELLO_ORB::status status = engine()->hello( (const char*)name.toLatin1() );
// update Object browser
getApp()->updateObjectBrowser(true);
if ( !name.trimmed().isEmpty() ) {
// say goodby to SALOME
- HELLO_ORB::status status = engine()->goodbye( _CAST(Study, studyDS)->GetStudy(), (const char*)name.toLatin1() );
+ HELLO_ORB::status status = engine()->goodbye( (const char*)name.toLatin1() );
// update Object browser
getApp()->updateObjectBrowser(true);
>> salome.salome_init()
>> import HELLO_ORB
>> c = container.load_impl("HELLO", "HELLO")
->> c.hello(salome.myStudy, "Christian")
+>> c.hello("Christian")
</pre>
The last instruction invokes HELLO module's service \a hello(). Proceed as
import salome
salome.salome_init()
c = test(clt)
- c.hello(salome.myStudy, "Christian")
+ c.hello("Christian")
</pre>
The test function creates the LifeCycle object. It then asks for the
<ul>
$navpath
<li class="footer">
- Copyright © 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE<br>
+ Copyright © 2007-2017 CEA/DEN, EDF R&D, OPEN CASCADE<br>
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS<br>
</li>
</ul>
{
/*!
\brief Say hello to \a name
- \param study SALOME study
\param name person's name
\return operation status
*/
- status hello( in SALOMEDS::Study study, in string name )
+ status hello( in string name )
raises (SALOME::SALOME_Exception);
/*!
\brief Say goodbye to \a name
- \param study SALOME study
\param name person's name
\return operation status
*/
- status goodbye( in SALOMEDS::Study study, in string name )
+ status goodbye( in string name )
raises (SALOME::SALOME_Exception);
/*!
<component-author>Vadim SANDLER</component-author>
<component-version>@SALOMEHELLO_VERSION@</component-version>
<component-comment>Sample module</component-comment>
- <component-multistudy>1</component-multistudy>
<component-impltype>1</component-impltype>
<component-icone>HELLO.png</component-icone>
<constraint></constraint>
<service-comment>Hello function</service-comment>
<service-by-default>1</service-by-default>
<inParameter-list>
- <inParameter>
- <inParameter-name>study</inParameter-name>
- <inParameter-type>Study</inParameter-type>
- <inParameter-comment>study</inParameter-comment>
- </inParameter>
<inParameter>
<inParameter-name>name</inParameter-name>
<inParameter-type>string</inParameter-type>
<service-comment>Goodbye function</service-comment>
<service-by-default>0</service-by-default>
<inParameter-list>
- <inParameter>
- <inParameter-name>study</inParameter-name>
- <inParameter-type>Study</inParameter-type>
- <inParameter-comment>study</inParameter-comment>
- </inParameter>
<inParameter>
<inParameter-name>name</inParameter-name>
<inParameter-type>string</inParameter-type>
${KERNEL_SalomeIDLKernel}
${KERNEL_OpUtil}
${KERNEL_SalomeContainer}
+ ${KERNEL_SalomeKernelHelpers}
SalomeIDLHELLO
)
#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)
/*!
\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::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 = KERNEL::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::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 = KERNEL::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() );
}
}
{
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 = KERNEL::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
const char* interfaceName );
virtual ~HELLO();
- HELLO_ORB::status hello ( SALOMEDS::Study_ptr study, const char* name );
- HELLO_ORB::status goodbye( SALOMEDS::Study_ptr study, const char* name );
+ HELLO_ORB::status hello ( const char* name );
+ HELLO_ORB::status goodbye( const char* name );
void copyOrMove( const HELLO_ORB::object_list& what,
SALOMEDS::SObject_ptr where,
CORBA::Long row, CORBA::Boolean isCopy );
Perform general module initialization (like creation of actions,
menus, toolbars, etc).
- \note This function is invoked only once per study, when the module
+ \note This function is invoked only once, when the module
is first time activated by the user.
The study associated with the application might not exist
(created or opened) when this function is invoked, so it is not
*/
void HELLOGUI::hello()
{
- SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
- _PTR(Study) studyDS = study->studyDS();
-
// request user name
bool ok;
QString name = QInputDialog::getText( getApp()->desktop(), tr( "QUE_HELLO_TITLE" ), tr( "QUE_ENTER_NAME" ),
if ( ok && !name.trimmed().isEmpty() ) {
// say hello to SALOME
- HELLO_ORB::status status = engine()->hello( _CAST(Study, studyDS)->GetStudy(), (const char*)name.toLatin1() );
+ HELLO_ORB::status status = engine()->hello( (const char*)name.toLatin1() );
// update Object browser
getApp()->updateObjectBrowser(true);
if ( !name.trimmed().isEmpty() ) {
// say goodby to SALOME
- HELLO_ORB::status status = engine()->goodbye( _CAST(Study, studyDS)->GetStudy(), (const char*)name.toLatin1() );
+ HELLO_ORB::status status = engine()->goodbye( (const char*)name.toLatin1() );
// update Object browser
getApp()->updateObjectBrowser(true);