Version: 9.15.0
YACS::ENGINE::CORBAComponent Class Reference

Class for CORBA component instance. More...

#include <CORBAComponent.hxx>

Inheritance diagram for YACS::ENGINE::CORBAComponent:
Collaboration diagram for YACS::ENGINE::CORBAComponent:

Public Member Functions

 CORBAComponent (const std::string &name)
 CORBAComponent constructor. More...
 
 CORBAComponent (const CORBAComponent &other)
 CORBAComponent copy constructor. More...
 
virtual ~CORBAComponent ()
 
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 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 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
 
virtual bool setContainer (Container *cont)
 
ContainergetContainer () const
 
virtual void attachOnCloning () const
 
virtual void dettachOnCloning () const
 
bool isAttachedOnCloning () const
 
virtual void shutdown (int level)
 
- 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 () const
 

Static Public Attributes

static const char KIND [] ="CORBA"
 
- 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 ()
 
- Protected Member Functions inherited from YACS::ENGINE::RefCounter
 RefCounter ()
 
 RefCounter (const RefCounter &other)
 
virtual ~RefCounter ()
 
- 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 CORBA component instance.

Definition at line 36 of file CORBAComponent.hxx.

Constructor & Destructor Documentation

◆ CORBAComponent() [1/2]

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

CORBAComponent constructor.

Definition at line 44 of file CORBAComponent.cxx.

44  : ComponentInstance(name)
45 {
46  _objComponent=CORBA::Object::_nil();
47 }
CORBA::Object_var _objComponent
ComponentInstance(const std::string &name)

References _objComponent.

Referenced by cloneAlways().

◆ CORBAComponent() [2/2]

CORBAComponent::CORBAComponent ( const CORBAComponent other)

CORBAComponent copy constructor.

Definition at line 50 of file CORBAComponent.cxx.

50  :ComponentInstance(other)
51 {
52  _objComponent=CORBA::Object::_nil();
53 }

References _objComponent.

◆ ~CORBAComponent()

CORBAComponent::~CORBAComponent ( )
virtual

Definition at line 55 of file CORBAComponent.cxx.

56 {
57 #ifdef REFCNT
58  DEBTRACE( "+++++++++++++++++" << getName() << " +++++++++++++++++" );
59  if(_objComponent != CORBA::Object::_nil())
60  {
61  std::cerr << "CORBAComponent::destructor:refcount: " <<_objComponent->_PR_getobj()->pd_refCount << std::endl;
62  }
63 #endif
64 }
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31

References _objComponent, and DEBTRACE.

Member Function Documentation

◆ clone()

ComponentInstance * CORBAComponent::clone ( ) const
virtual

Clone the component instance.

Implements YACS::ENGINE::ComponentInstance.

Definition at line 180 of file CORBAComponent.cxx.

181 {
182  //no real need to clone a CORBA Component : there is no component instance loading
183  incrRef();
184  return (ComponentInstance*)this;
185  //return new CORBAComponent(*this);
186 }
Base class for all component instances.

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

◆ cloneAlways()

ComponentInstance * CORBAComponent::cloneAlways ( ) const
virtual

Implements YACS::ENGINE::ComponentInstance.

Definition at line 188 of file CORBAComponent.cxx.

189 {
190  return new CORBAComponent(*this);
191 }
CORBAComponent(const std::string &name)
CORBAComponent constructor.

References CORBAComponent().

◆ createNode()

ServiceNode * CORBAComponent::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 CORBANode node

Implements YACS::ENGINE::ComponentInstance.

Definition at line 172 of file CORBAComponent.cxx.

173 {
174  CORBANode* node= new CORBANode(name);
175  node->setComponent(this);
176  return node;
177 }
Class for CORBA Service Node.
Definition: CORBANode.hxx:45
virtual void setComponent(ComponentInstance *compo)
Associate an existing component instance to this service node AND check the consistency regarding the...

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

◆ getCompoPtr()

CORBA::Object_ptr CORBAComponent::getCompoPtr ( )
virtual

Definition at line 83 of file CORBAComponent.cxx.

84 {
85 #ifdef REFCNT
86  std::cerr << "CORBAComponent::getCompoPtr:refCount: " <<_objComponent->_PR_getobj()->pd_refCount << std::endl;
87 #endif
88  return CORBA::Object::_duplicate(_objComponent);
89 }

References _objComponent.

◆ getFileRepr()

std::string CORBAComponent::getFileRepr ( ) const
virtual

For dump in file.

Reimplemented from YACS::ENGINE::ComponentInstance.

Definition at line 193 of file CORBAComponent.cxx.

194 {
195  ostringstream stream;
196  stream << "<ref>" << getCompoName() << "</ref>";
197  return stream.str();
198 }
const std::string & getCompoName() const

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

◆ getKind()

std::string CORBAComponent::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 66 of file CORBAComponent.cxx.

67 {
68  return KIND;
69 }

References KIND.

◆ getKindForNode()

std::string CORBAComponent::getKindForNode ( ) const
virtual

Reimplemented from YACS::ENGINE::ComponentInstance.

Definition at line 71 of file CORBAComponent.cxx.

72 {
73  return KIND;
74 }

References KIND.

◆ isLoaded()

bool CORBAComponent::isLoaded ( Task askingNode) const
virtual

Is the component instance already loaded ?

Implements YACS::ENGINE::ComponentInstance.

Definition at line 92 of file CORBAComponent.cxx.

93 {
94  if(CORBA::is_nil(_objComponent))
95  return false;
96  else
97  return true;
98 }

References _objComponent.

◆ load()

void CORBAComponent::load ( Task askingNode)
virtual

Load the component.

Implements YACS::ENGINE::ComponentInstance.

Definition at line 101 of file CORBAComponent.cxx.

102 {
103  DEBTRACE( "CORBAComponent::load" );
104  try
105  {
106  DEBTRACE( "+++++++++++++++++" << getCompoName() << " +++++++++++++++++" );
108 #ifdef REFCNT
109  std::cerr << "CORBAComponent::load:refCount: " <<_objComponent->_PR_getobj()->pd_refCount << std::endl;
110 #endif
111  }
112  catch(CORBA::COMM_FAILURE& ex)
113  {
114  cerr << "Caught system exception COMM_FAILURE -- unable to contact the "
115  << "object." << endl;
116  throw Exception("Execution problem");
117  }
118  catch(CORBA::SystemException& ex)
119  {
120  cerr << "Caught a CORBA::SystemException." ;
121  CORBA::Any tmp;
122  tmp <<= ex;
123  CORBA::TypeCode_var tc = tmp.type();
124  const char *p = tc->name();
125  if ( *p != '\0' )
126  cerr <<p;
127  else
128  cerr << tc->id();
129  cerr << endl;
130  throw Exception("Execution problem");
131  }
132  catch(CORBA::Exception& ex)
133  {
134  cerr << "Caught CORBA::Exception. " ;
135  CORBA::Any tmp;
136  tmp <<= ex;
137  CORBA::TypeCode_var tc = tmp.type();
138  const char *p = tc->name();
139  if ( *p != '\0' )
140  cerr <<p;
141  else
142  cerr << tc->id();
143  cerr << endl;
144  throw Exception("Execution problem");
145  }
146  catch(omniORB::fatalException& fe)
147  {
148  cerr << "Caught omniORB::fatalException:" << endl;
149  cerr << " file: " << fe.file() << endl;
150  cerr << " line: " << fe.line() << endl;
151  cerr << " mesg: " << fe.errmsg() << endl;
152  throw Exception("Execution problem");
153  }
154  catch(...)
155  {
156  cerr << "Caught unknown exception." << endl;
157  throw Exception("Execution problem");
158  }
159  if( CORBA::is_nil(_objComponent) )
160  {
161  cerr << "Can't get reference to object (or it was nil)." << endl;
162  throw Exception("Execution problem");
163  }
164  //TODO: if IOR is valid but the component does not exist, it works (bad)
165 }
CORBA::Object_var getFromNS(const char *entry) const
Proc * p
Definition: driver.cxx:216
YACSRUNTIMESALOME_EXPORT RuntimeSALOME * getSALOMERuntime()

References _objComponent, DEBTRACE, testCppPluginInvokation::ex, YACS::ENGINE::ComponentInstance::getCompoName(), YACS::ENGINE::RuntimeSALOME::getFromNS(), YACS::ENGINE::getSALOMERuntime(), and p.

◆ unload()

void CORBAComponent::unload ( Task askingNode)
virtual

Unload the component.

Implements YACS::ENGINE::ComponentInstance.

Definition at line 77 of file CORBAComponent.cxx.

78 {
79  //Not implemented
80  std::cerr << "CORBAComponent::unload : not implemented " << std::endl;
81 }

Member Data Documentation

◆ _objComponent

CORBA::Object_var YACS::ENGINE::CORBAComponent::_objComponent
protected

Definition at line 55 of file CORBAComponent.hxx.

Referenced by CORBAComponent(), getCompoPtr(), isLoaded(), load(), and ~CORBAComponent().

◆ KIND

const char CORBAComponent::KIND ="CORBA"
static

Definition at line 51 of file CORBAComponent.hxx.

Referenced by getKind(), and getKindForNode().


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