Version: 9.15.0
YACS::ENGINE::SalomeContainer Class Reference

#include <SalomeContainer.hxx>

Inheritance diagram for YACS::ENGINE::SalomeContainer:
Collaboration diagram for YACS::ENGINE::SalomeContainer:

Public Member Functions

 SalomeContainer ()
 
 SalomeContainer (const SalomeContainer &other)
 
 SalomeContainer (const Container &other, const SalomeContainerTools &sct, const SalomeContainerHelper *lmt, const std::vector< std::string > &componentNames, int shutdownLev)
 
void lock ()
 For thread safety for concurrent load operation on same Container. More...
 
void unLock ()
 For thread safety for concurrent load operation on same Container. More...
 
std::string getKind () const
 
bool isAlreadyStarted (const Task *askingNode) const
 Check if the component instance container is already started. More...
 
Engines::Container_ptr getContainerPtr (const Task *askingNode) const
 
void start (const Task *askingNode) override
 Start a salome container (true salome container not yacs one) with given ContainerParameters (_params) More...
 
void start (const Task *askingNode, const std::string &resource_name, const std::string &container_name) override
 
bool canAcceptImposedResource () override
 
Containerclone () const
 WARNING ! clone behaviour MUST be in coherence with what is returned by isAttachedOnCloning() method More...
 
ContainercloneAlways () const
 
std::string getPlacementId (const Task *askingNode) const
 Get the container placement id for a component instance. More...
 
std::string getFullPlacementId (const Task *askingNode) const
 Get the container full path for a component instance. More...
 
void checkCapabilityToDealWith (const ComponentInstance *inst) const
 
void setProperty (const std::string &name, const std::string &value)
 
std::string getProperty (const std::string &name) const
 
void clearProperties ()
 
void addComponentName (const std::string &name)
 
void addToResourceList (const std::string &name)
 
virtual CORBA::Object_ptr loadComponent (Task *inst)
 Load a component instance in this container. More...
 
void shutdown (int level)
 
std::map< std::string, std::string > getResourceProperties (const std::string &name) const
 
std::map< std::string, std::string > getProperties () const
 
- Public Member Functions inherited from YACS::ENGINE::Container
virtual std::string getDiscreminantStrOfThis (const Task *askingNode) const
 
virtual bool isUsingPythonCache ()
 
virtual void usePythonCache (bool v)
 
virtual void setAttachOnCloningStatus (bool val) const
 
virtual void attachOnCloning () const
 
virtual void dettachOnCloning () const
 
virtual bool isAttachedOnCloning () const
 
virtual bool isSupportingRTODefNbOfComp () const
 
virtual void setProperties (const std::map< std::string, std::string > &properties)
 
virtual std::string getName () const
 
void setName (std::string name)
 WARNING ! name is used in edition to identify different containers, it is not the runtime name of the container More...
 
void setProc (Proc *proc)
 
ProcgetProc ()
 
- Public Member Functions inherited from YACS::ENGINE::RefCounter
unsigned int getRefCnt () const
 
void incrRef () const
 
bool decrRef () const
 

Static Public Attributes

static const char KIND [] ="Salome"
 
static const char TYPE_PROPERTY_STR [] ="type"
 
- Static Public Attributes inherited from YACS::ENGINE::Container
static const char KIND_ENTRY [] ="container_kind"
 
static const char AOC_ENTRY [] ="attached_on_cloning"
 
static const char USE_PYCACHE_PROPERTY [] ="use_py_cache"
 
- Static Public Attributes inherited from YACS::ENGINE::RefCounter
static unsigned int _totalCnt =0
 

Protected Member Functions

virtual ~SalomeContainer ()
 
- Protected Member Functions inherited from YACS::ENGINE::Container
 Container ()
 
virtual ~Container ()
 
- Protected Member Functions inherited from YACS::ENGINE::RefCounter
 RefCounter ()
 
 RefCounter (const RefCounter &other)
 
virtual ~RefCounter ()
 

Protected Attributes

YACS::BASES::Mutex _mutex
 thread safety in Salome ??? More...
 
std::vector< std::string > _componentNames
 
SalomeContainerHelper_launchModeType
 
int _shutdownLevel
 
SalomeContainerTools _sct
 
- Protected Attributes inherited from YACS::ENGINE::Container
std::string _name
 
bool _isAttachedOnCloning
 
Proc_proc
 
- Protected Attributes inherited from YACS::ENGINE::RefCounter
unsigned int _cnt
 

Friends

class SalomeComponent
 

Detailed Description

Definition at line 38 of file SalomeContainer.hxx.

Constructor & Destructor Documentation

◆ SalomeContainer() [1/3]

SalomeContainer::SalomeContainer ( )

◆ SalomeContainer() [2/3]

SalomeContainer::SalomeContainer ( const SalomeContainer other)

Definition at line 62 of file SalomeContainer.cxx.

66  _sct(other._sct)
67 {
68 }
virtual SalomeContainerHelper * deepCpyOnlyStaticInfo() const =0
std::vector< std::string > _componentNames

◆ SalomeContainer() [3/3]

SalomeContainer::SalomeContainer ( const Container other,
const SalomeContainerTools sct,
const SalomeContainerHelper lmt,
const std::vector< std::string > &  componentNames,
int  shutdownLev 
)

Definition at line 70 of file SalomeContainer.cxx.

71  :Container(other),_componentNames(componentNames),
72  _launchModeType(const_cast<SalomeContainerHelper *>(lmt)),_shutdownLevel(shutdownLev),_sct(sct)
73 {
74  if(lmt)
75  lmt->incrRef();
76 }

References YACS::ENGINE::RefCounter::incrRef().

◆ ~SalomeContainer()

SalomeContainer::~SalomeContainer ( )
protectedvirtual

Definition at line 78 of file SalomeContainer.cxx.

79 {
81 }

References _launchModeType, and YACS::ENGINE::RefCounter::decrRef().

Member Function Documentation

◆ addComponentName()

void SalomeContainer::addComponentName ( const std::string &  name)
virtual

Implements YACS::ENGINE::Container.

Definition at line 165 of file SalomeContainer.cxx.

166 {
167  _componentNames.push_back(name);
168 }

References _componentNames.

◆ addToResourceList()

void SalomeContainer::addToResourceList ( const std::string &  name)

Definition at line 170 of file SalomeContainer.cxx.

171 {
172  _sct.addToResourceList(name);
173 }
void addToResourceList(const std::string &name) override

References _sct, and YACS::ENGINE::SalomeContainerTools::addToResourceList().

◆ canAcceptImposedResource()

bool SalomeContainer::canAcceptImposedResource ( )
overridevirtual

◆ checkCapabilityToDealWith()

void SalomeContainer::checkCapabilityToDealWith ( const ComponentInstance inst) const
virtual

Implements YACS::ENGINE::Container.

Definition at line 114 of file SalomeContainer.cxx.

115 {
116  if(inst->getKind()!=SalomeComponent::KIND)
117  throw Exception("SalomeContainer::checkCapabilityToDealWith : SalomeContainer is not able to deal with this type of ComponentInstance.");
118 }
virtual std::string getKind() const
Return the component kind.

References YACS::ENGINE::ComponentInstance::getKind(), and YACS::ENGINE::SalomeComponent::KIND.

◆ clearProperties()

void SalomeContainer::clearProperties ( )
virtual

◆ clone()

Container * SalomeContainer::clone ( ) const
virtual

WARNING ! clone behaviour MUST be in coherence with what is returned by isAttachedOnCloning() method

Implements YACS::ENGINE::Container.

Definition at line 98 of file SalomeContainer.cxx.

99 {
101  {
102  incrRef();
103  return (Container*) (this);
104  }
105  else
106  return new SalomeContainer(*this);
107 }

References YACS::ENGINE::Container::_isAttachedOnCloning, YACS::ENGINE::RefCounter::incrRef(), and SalomeContainer().

◆ cloneAlways()

Container * SalomeContainer::cloneAlways ( ) const
virtual

Implements YACS::ENGINE::Container.

Definition at line 109 of file SalomeContainer.cxx.

110 {
111  return new SalomeContainer(*this);
112 }

References SalomeContainer().

◆ getContainerPtr()

Engines::Container_ptr SalomeContainer::getContainerPtr ( const Task askingNode) const

Definition at line 214 of file SalomeContainer.cxx.

215 {
216  return Engines::Container::_duplicate(_launchModeType->getContainer(askingNode));
217 }
virtual Engines::Container_var getContainer(const Task *askingNode) const =0

References _launchModeType, and YACS::ENGINE::SalomeContainerHelper::getContainer().

Referenced by YACS::ENGINE::PythonEntry::GetContainerLog(), GetContainerObj(), and YACS::ENGINE::DistributedPythonNode::load().

◆ getFullPlacementId()

std::string SalomeContainer::getFullPlacementId ( const Task askingNode) const
virtual

Get the container full path for a component instance.

Parameters
instthe component instance
Returns
the full placement id

Implements YACS::ENGINE::Container.

Definition at line 199 of file SalomeContainer.cxx.

200 {
202 }
static std::string GetFullPlacementId(const SalomeContainerHelper *launchModeType, const Container *cont, const Task *askingNode)

References _launchModeType, and YACS::ENGINE::SalomeContainerToolsBase::GetFullPlacementId().

◆ getKind()

std::string SalomeContainer::getKind ( ) const
virtual

Implements YACS::ENGINE::Container.

Definition at line 93 of file SalomeContainer.cxx.

94 {
95  return KIND;
96 }

References KIND.

◆ getPlacementId()

std::string SalomeContainer::getPlacementId ( const Task askingNode) const
virtual

Get the container placement id for a component instance.

Parameters
instthe component instance
Returns
the placement id

Implements YACS::ENGINE::Container.

Definition at line 189 of file SalomeContainer.cxx.

190 {
192 }
static std::string GetPlacementId(const SalomeContainerHelper *launchModeType, const Container *cont, const Task *askingNode)

References _launchModeType, and YACS::ENGINE::SalomeContainerToolsBase::GetPlacementId().

◆ getProperties()

std::map< std::string, std::string > SalomeContainer::getProperties ( ) const
virtual

Implements YACS::ENGINE::Container.

Definition at line 268 of file SalomeContainer.cxx.

269 {
270  return _sct.getProperties();
271 }
const std::map< std::string, std::string > & getProperties() const override

References _sct, and YACS::ENGINE::SalomeContainerTools::getProperties().

◆ getProperty()

std::string SalomeContainer::getProperty ( const std::string &  name) const
virtual

Implements YACS::ENGINE::Container.

Definition at line 147 of file SalomeContainer.cxx.

148 {
149  if (name == TYPE_PROPERTY_STR)
150  return _launchModeType->getType();
151  if (name==AOC_ENTRY)
152  {
153  int reti(_isAttachedOnCloning);
154  std::ostringstream oss; oss << reti;
155  return oss.str();
156  }
157  return _sct.getProperty(name);
158 }
static const char AOC_ENTRY[]
Definition: Container.hxx:88
std::string getProperty(const std::string &name) const override
static const char TYPE_PROPERTY_STR[]

References YACS::ENGINE::Container::_isAttachedOnCloning, _launchModeType, _sct, YACS::ENGINE::Container::AOC_ENTRY, YACS::ENGINE::SalomeContainerTools::getProperty(), YACS::ENGINE::SalomeContainerHelper::getType(), and TYPE_PROPERTY_STR.

◆ getResourceProperties()

std::map< std::string, std::string > SalomeContainer::getResourceProperties ( const std::string &  name) const
virtual

Implements YACS::ENGINE::Container.

Definition at line 263 of file SalomeContainer.cxx.

264 {
265  return _sct.getResourceProperties(name);
266 }
std::map< std::string, std::string > getResourceProperties(const std::string &name) const override

References _sct, and YACS::ENGINE::SalomeContainerTools::getResourceProperties().

◆ isAlreadyStarted()

bool SalomeContainer::isAlreadyStarted ( const Task askingNode) const
virtual

Check if the component instance container is already started.

Parameters
instthe component instance
Returns
true, if the container is already started, else false

Implements YACS::ENGINE::Container.

Definition at line 209 of file SalomeContainer.cxx.

210 {
211  return _launchModeType->isAlreadyStarted(askingNode);
212 }
virtual bool isAlreadyStarted(const Task *askingNode) const =0

References _launchModeType, and YACS::ENGINE::SalomeContainerHelper::isAlreadyStarted().

Referenced by YACS::ENGINE::SalomeContainerTmpForHP::loadComponent().

◆ loadComponent()

CORBA::Object_ptr SalomeContainer::loadComponent ( Task askingNode)
virtual

Load a component instance in this container.

Parameters
instthe component instance to load

Reimplemented in YACS::ENGINE::SalomeContainerTmpForHP.

Definition at line 179 of file SalomeContainer.cxx.

180 {
182 }
static CORBA::Object_ptr LoadComponent(SalomeContainerHelper *launchModeType, Container *cont, Task *askingNode)

References _launchModeType, and YACS::ENGINE::SalomeContainerToolsBase::LoadComponent().

Referenced by YACS::ENGINE::SalomeComponent::load().

◆ lock()

void SalomeContainer::lock ( )
virtual

For thread safety for concurrent load operation on same Container.

Implements YACS::ENGINE::Container.

Definition at line 83 of file SalomeContainer.cxx.

84 {
85  _mutex.lock();
86 }
YACS::BASES::Mutex _mutex
thread safety in Salome ???

References _mutex.

◆ setProperty()

void SalomeContainer::setProperty ( const std::string &  name,
const std::string &  value 
)
virtual

Implements YACS::ENGINE::Container.

Definition at line 120 of file SalomeContainer.cxx.

121 {
122  if (name == AOC_ENTRY)
123  {
124  std::istringstream iss(value);
125  int val;
126  iss >> val;
127  setAttachOnCloningStatus((bool)val);
128  }
129  else if (name == TYPE_PROPERTY_STR)
130  {
132  {
135  }
136  else if (value == SalomeContainerMultiHelper::TYPE_NAME)
137  {
140  }
141  else
142  throw Exception("SalomeContainer::setProperty : type value is not correct (mono or multi): " + value);
143  }
144  _sct.setProperty(name,value);
145 }
virtual void setAttachOnCloningStatus(bool val) const
Definition: Container.cxx:68
void setProperty(const std::string &name, const std::string &value) override

References _launchModeType, _sct, YACS::ENGINE::Container::AOC_ENTRY, YACS::ENGINE::RefCounter::decrRef(), YACS::ENGINE::Container::setAttachOnCloningStatus(), YACS::ENGINE::SalomeContainerTools::setProperty(), YACS::ENGINE::SalomeContainerMonoHelper::TYPE_NAME, YACS::ENGINE::SalomeContainerMultiHelper::TYPE_NAME, and TYPE_PROPERTY_STR.

◆ shutdown()

void SalomeContainer::shutdown ( int  level)
virtual

Implements YACS::ENGINE::Container.

Definition at line 252 of file SalomeContainer.cxx.

253 {
254  DEBTRACE("SalomeContainer::shutdown: " << _name << "," << level << "," << _shutdownLevel);
255  if(level < _shutdownLevel)
256  return;
257 
258  _shutdownLevel=999;
259  //shutdown the SALOME containers
261 }
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31

References _launchModeType, YACS::ENGINE::Container::_name, _shutdownLevel, DEBTRACE, and YACS::ENGINE::SalomeContainerHelper::shutdown().

◆ start() [1/2]

void SalomeContainer::start ( const Task askingNode)
overridevirtual

Start a salome container (true salome container not yacs one) with given ContainerParameters (_params)

Parameters
instthe component instance

Implements YACS::ENGINE::Container.

Definition at line 223 of file SalomeContainer.cxx.

224 {
226 }
static void Start(const std::vector< std::string > &compoNames, SalomeContainerHelper *schelp, SalomeContainerToolsBase &sct, int &shutdownLevel, const Container *cont, const Task *askingNode)

References _componentNames, _launchModeType, _sct, _shutdownLevel, and YACS::ENGINE::SalomeContainerToolsBase::Start().

Referenced by YACS::ENGINE::SalomeContainerTmpForHP::loadComponent(), and start().

◆ start() [2/2]

void SalomeContainer::start ( const Task askingNode,
const std::string &  resource_name,
const std::string &  container_name 
)
overridevirtual

Reimplemented from YACS::ENGINE::Container.

Definition at line 228 of file SalomeContainer.cxx.

231 {
233  && askingNode != nullptr
234  && askingNode->hasImposedResource())
235  {
236  SalomeContainerTools tempSct = _sct;
237  tempSct.setProperty("name", resource_name);
238  tempSct.setProperty("container_name", container_name);
239  // components are not supported yet on this kind of start
240  std::vector<std::string> noComponentNames;
241  SalomeContainerTools::Start(noComponentNames,_launchModeType,tempSct,_shutdownLevel,this,askingNode);
242  }
243  else
244  start(askingNode);
245 }
void start(const Task *askingNode) override
Start a salome container (true salome container not yacs one) with given ContainerParameters (_params...
bool canAcceptImposedResource() override
virtual bool hasImposedResource() const
Definition: Task.hxx:58

References _launchModeType, _sct, _shutdownLevel, canAcceptImposedResource(), YACS::ENGINE::Task::hasImposedResource(), YACS::ENGINE::SalomeContainerTools::setProperty(), YACS::ENGINE::SalomeContainerToolsBase::Start(), and start().

◆ unLock()

void SalomeContainer::unLock ( )
virtual

For thread safety for concurrent load operation on same Container.

Implements YACS::ENGINE::Container.

Definition at line 88 of file SalomeContainer.cxx.

89 {
90  _mutex.unLock();
91 }

References _mutex.

Friends And Related Function Documentation

◆ SalomeComponent

friend class SalomeComponent
friend

Definition at line 40 of file SalomeContainer.hxx.

Member Data Documentation

◆ _componentNames

std::vector<std::string> YACS::ENGINE::SalomeContainer::_componentNames
protected

Definition at line 83 of file SalomeContainer.hxx.

Referenced by addComponentName(), and start().

◆ _launchModeType

◆ _mutex

YACS::BASES::Mutex YACS::ENGINE::SalomeContainer::_mutex
protected

thread safety in Salome ???

Definition at line 82 of file SalomeContainer.hxx.

Referenced by lock(), and unLock().

◆ _sct

SalomeContainerTools YACS::ENGINE::SalomeContainer::_sct
protected

◆ _shutdownLevel

int YACS::ENGINE::SalomeContainer::_shutdownLevel
protected

Definition at line 85 of file SalomeContainer.hxx.

Referenced by shutdown(), and start().

◆ KIND

const char SalomeContainer::KIND ="Salome"
static

Definition at line 74 of file SalomeContainer.hxx.

Referenced by getKind().

◆ TYPE_PROPERTY_STR

const char SalomeContainer::TYPE_PROPERTY_STR ="type"
static

Definition at line 75 of file SalomeContainer.hxx.

Referenced by getProperty(), and setProperty().


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