Version: 8.3.0
YACS::ENGINE::SalomeComponent Class Reference

Class for Salome component instance. More...

#include <SalomeComponent.hxx>

Inheritance diagram for YACS::ENGINE::SalomeComponent:
Collaboration diagram for YACS::ENGINE::SalomeComponent:

Public Member Functions

 SalomeComponent (const std::string &name)
 SalomeComponent constructor. More...
 
 SalomeComponent (const SalomeComponent &other)
 SalomeComponent copy constructor. More...
 
virtual ~SalomeComponent ()
 
virtual void load (Task *askingNode)
 Load the component. More...
 
virtual void unload (Task *askingNode)
 Unload the component. More...
 
virtual bool isLoaded (Task *askingNode) const
 Is the component instance already loaded ? More...
 
virtual bool setContainer (Container *cont)
 
virtual ServiceNodecreateNode (const std::string &name)
 Create a ServiceNode with this component instance and no input or output port. More...
 
virtual ComponentInstanceclone () const
 Clone the component instance. More...
 
virtual ComponentInstancecloneAlways () const
 
virtual std::string getFileRepr () const
 For dump in file. More...
 
virtual CORBA::Object_ptr getCompoPtr ()
 
virtual void shutdown (int level)
 
virtual std::string getKind () const
 Return the component kind. More...
 
virtual std::string getKindForNode () const
 
- Public Member Functions inherited from YACS::ENGINE::ComponentInstance
 ComponentInstance (const std::string &name)
 
 ComponentInstance (const ComponentInstance &other)
 
const std::string & getCompoName () const
 
const std::string & getInstanceName () const
 
void setName (const std::string &name)
 
virtual void setAnonymous (bool anon)
 
virtual bool isAnonymous ()
 
int getNumId () const
 
ContainergetContainer () const
 
virtual void attachOnCloning () const
 
virtual void dettachOnCloning () const
 
bool isAttachedOnCloning () const
 
- Public Member Functions inherited from YACS::ENGINE::PropertyInterface
virtual ~PropertyInterface ()
 
virtual void setProperty (const std::string &name, const std::string &value)
 
virtual std::string getProperty (const std::string &name)
 Get a property value given its name. More...
 
std::map< std::string,
std::string > 
getProperties () const
 
virtual void setProperties (std::map< std::string, std::string > properties)
 
- Public Member Functions inherited from YACS::ENGINE::RefCounter
unsigned int getRefCnt () const
 
void incrRef () const
 
bool decrRef ()
 

Static Public Attributes

static const char KIND [] ="Salome"
 
- Static Public Attributes inherited from YACS::ENGINE::ComponentInstance
static const char KIND [] =""
 
- Static Public Attributes inherited from YACS::ENGINE::RefCounter
static unsigned int _totalCnt =0
 

Protected Attributes

CORBA::Object_var _objComponent
 
- Protected Attributes inherited from YACS::ENGINE::ComponentInstance
std::string _compoName
 WARNING : _compoName identify only the component type. More...
 
std::string _instanceName
 WARNING : _InstanceName has a strong semantic. It discriminates ComponentInstance instances each other. More...
 
int _numId
 
Container_container
 
bool _isAttachedOnCloning
 
bool _anonymous
 
- Protected Attributes inherited from YACS::ENGINE::PropertyInterface
std::map< std::string,
std::string > 
_propertyMap
 
- Protected Attributes inherited from YACS::ENGINE::RefCounter
unsigned int _cnt
 

Additional Inherited Members

- Protected Member Functions inherited from YACS::ENGINE::ComponentInstance
virtual ~ComponentInstance ()
 
- Static Protected Attributes inherited from YACS::ENGINE::ComponentInstance
static const char NULL_FILE_REPR [] ="No repr specified for ComponentInstance"
 
static int _total = 0
 

Detailed Description

Class for Salome component instance.

Definition at line 35 of file SalomeComponent.hxx.

Constructor & Destructor Documentation

SalomeComponent::SalomeComponent ( const std::string &  name)

SalomeComponent constructor.

Definition at line 45 of file SalomeComponent.cxx.

References _objComponent.

Referenced by clone(), and cloneAlways().

45  : ComponentInstance(name)
46 {
47  _objComponent=CORBA::Object::_nil();
48 }
SalomeComponent::SalomeComponent ( const SalomeComponent other)

SalomeComponent copy constructor.

Definition at line 51 of file SalomeComponent.cxx.

References _objComponent.

51  :ComponentInstance(other)
52 {
53  _objComponent=CORBA::Object::_nil();
54 }
SalomeComponent::~SalomeComponent ( )
virtual

Definition at line 56 of file SalomeComponent.cxx.

57 {
58 }

Member Function Documentation

ComponentInstance * SalomeComponent::clone ( ) const
virtual

Clone the component instance.

Implements YACS::ENGINE::ComponentInstance.

Definition at line 130 of file SalomeComponent.cxx.

References YACS::ENGINE::ComponentInstance::_isAttachedOnCloning, YACS::ENGINE::RefCounter::incrRef(), and SalomeComponent().

131 {
133  {
134  incrRef();
135  return (ComponentInstance*) (this);
136  }
137  else
138  return new SalomeComponent(*this);
139 }
ComponentInstance * SalomeComponent::cloneAlways ( ) const
virtual

Implements YACS::ENGINE::ComponentInstance.

Definition at line 141 of file SalomeComponent.cxx.

References SalomeComponent().

142 {
143  return new SalomeComponent(*this);
144 }
ServiceNode * SalomeComponent::createNode ( const std::string &  name)
virtual

Create a ServiceNode with this component instance and no input or output port.

Parameters
name: node name
Returns
a new SalomeNode node

Implements YACS::ENGINE::ComponentInstance.

Definition at line 122 of file SalomeComponent.cxx.

References YACS::ENGINE::ServiceNode::setComponent().

123 {
124  SalomeNode* node=new SalomeNode(name);
125  node->setComponent(this);
126  return node;
127 }
virtual CORBA::Object_ptr YACS::ENGINE::SalomeComponent::getCompoPtr ( )
inlinevirtual

Definition at line 49 of file SalomeComponent.hxx.

49 {return CORBA::Object::_duplicate(_objComponent);}
std::string SalomeComponent::getFileRepr ( ) const
virtual

For dump in file.

Reimplemented from YACS::ENGINE::ComponentInstance.

Definition at line 146 of file SalomeComponent.cxx.

References YACS::ENGINE::ComponentInstance::getCompoName().

147 {
148  ostringstream stream;
149  stream << "<component>" << getCompoName() << "</component>";
150  return stream.str();
151 }
std::string SalomeComponent::getKind ( ) const
virtual

Return the component kind.

A runtime can provide several implementations of a component instance. Each implementation has a different kind. A ComponentInstance can be associated to a ServiceNode is they have the same kind.

Reimplemented from YACS::ENGINE::ComponentInstance.

Definition at line 60 of file SalomeComponent.cxx.

References KIND.

61 {
62  return KIND;
63 }
std::string SalomeComponent::getKindForNode ( ) const
virtual

Reimplemented from YACS::ENGINE::ComponentInstance.

Definition at line 65 of file SalomeComponent.cxx.

References KIND.

66 {
67  return KIND;
68 }
bool SalomeComponent::isLoaded ( Task askingNode) const
virtual

Is the component instance already loaded ?

Implements YACS::ENGINE::ComponentInstance.

Definition at line 78 of file SalomeComponent.cxx.

References _objComponent.

79 {
80  if(CORBA::is_nil(_objComponent))
81  return false;
82  else
83  return true;
84 }
void SalomeComponent::load ( Task askingNode)
virtual

Load the component.

Implements YACS::ENGINE::ComponentInstance.

Definition at line 88 of file SalomeComponent.cxx.

References YACS::ENGINE::ComponentInstance::_compoName, YACS::ENGINE::ComponentInstance::_container, _objComponent, YACS::ENGINE::getSALOMERuntime(), and YACS::ENGINE::SalomeContainer::loadComponent().

89 {
90  if(_container)
91  {
92  SalomeContainer *salomeContainer(dynamic_cast<SalomeContainer *>(_container));
93  if(salomeContainer)
94  {
95  _objComponent=salomeContainer->loadComponent(askingNode);
96  return ;
97  }
98  throw Exception("Unrecognized type of Container ! Only Salome are supported by the Salome components !");
99  }
100  //throw Exception("SalomeComponent::load : no container specified !!! To be implemented in executor to allocate default a Container in case of presenceOfDefaultContainer.");
101  //This component has no specified container : use default container policy
102  SALOME_NamingService ns(getSALOMERuntime()->getOrb());
103  SALOME_LifeCycleCORBA LCC(&ns);
104  Engines::ContainerParameters params;
105  LCC.preSet(params);
106  params.resource_params.name = "localhost";
107  params.container_name ="FactoryServer";
108  _objComponent=LCC.LoadComponent(params,_compoName.c_str());
109 }
bool SalomeComponent::setContainer ( Container cont)
virtual

Reimplemented from YACS::ENGINE::ComponentInstance.

Definition at line 153 of file SalomeComponent.cxx.

References YACS::ENGINE::ComponentInstance::_compoName, YACS::ENGINE::ComponentInstance::_container, YACS::ENGINE::Container::addComponentName(), and YACS::ENGINE::ComponentInstance::setContainer().

154 {
155  if(!dynamic_cast<SalomeContainer *>(cont))
156  throw Exception("SalomeComponent::setContainer : a Salome component must be attached to a Salome container !");
158  {
159  if(_container)
161  return true;
162  }
163  else
164  return false;
165 }
void SalomeComponent::shutdown ( int  level)
virtual

Reimplemented from YACS::ENGINE::ComponentInstance.

Definition at line 167 of file SalomeComponent.cxx.

References YACS::ENGINE::ComponentInstance::_container, DEBTRACE, and YACS::ENGINE::Container::shutdown().

168 {
169  DEBTRACE("SalomeComponent::shutdown " << level);
170  if(_container)
171  _container->shutdown(level);
172 }
void SalomeComponent::unload ( Task askingNode)
virtual

Unload the component.

Implements YACS::ENGINE::ComponentInstance.

Definition at line 71 of file SalomeComponent.cxx.

72 {
73  //Not implemented
74  std::cerr << "SalomeComponent::unload : not implemented " << std::endl;
75 }

Member Data Documentation

CORBA::Object_var YACS::ENGINE::SalomeComponent::_objComponent
protected

Definition at line 56 of file SalomeComponent.hxx.

Referenced by isLoaded(), load(), and SalomeComponent().


The documentation for this class was generated from the following files: