Version: 8.3.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 ()
 

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 ()
 
- 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::CORBAComponent ( const std::string &  name)

CORBAComponent constructor.

Definition at line 44 of file CORBAComponent.cxx.

References _objComponent.

Referenced by cloneAlways().

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

CORBAComponent copy constructor.

Definition at line 50 of file CORBAComponent.cxx.

References _objComponent.

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

Definition at line 55 of file CORBAComponent.cxx.

References _objComponent, and DEBTRACE.

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 }

Member Function Documentation

ComponentInstance * CORBAComponent::clone ( ) const
virtual

Clone the component instance.

Implements YACS::ENGINE::ComponentInstance.

Definition at line 182 of file CORBAComponent.cxx.

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

183 {
184  //no real need to clone a CORBA Component : there is no component instance loading
185  incrRef();
186  return (ComponentInstance*)this;
187  //return new CORBAComponent(*this);
188 }
ComponentInstance * CORBAComponent::cloneAlways ( ) const
virtual

Implements YACS::ENGINE::ComponentInstance.

Definition at line 190 of file CORBAComponent.cxx.

References CORBAComponent().

191 {
192  return new CORBAComponent(*this);
193 }
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 174 of file CORBAComponent.cxx.

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

175 {
176  CORBANode* node= new CORBANode(name);
177  node->setComponent(this);
178  return node;
179 }
CORBA::Object_ptr CORBAComponent::getCompoPtr ( )
virtual

Definition at line 83 of file CORBAComponent.cxx.

References _objComponent.

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 }
std::string CORBAComponent::getFileRepr ( ) const
virtual

For dump in file.

Reimplemented from YACS::ENGINE::ComponentInstance.

Definition at line 195 of file CORBAComponent.cxx.

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

196 {
197  ostringstream stream;
198  stream << "<ref>" << getCompoName() << "</ref>";
199  return stream.str();
200 }
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.

References KIND.

67 {
68  return KIND;
69 }
std::string CORBAComponent::getKindForNode ( ) const
virtual

Reimplemented from YACS::ENGINE::ComponentInstance.

Definition at line 71 of file CORBAComponent.cxx.

References KIND.

72 {
73  return KIND;
74 }
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.

References _objComponent.

93 {
94  if(CORBA::is_nil(_objComponent))
95  return false;
96  else
97  return true;
98 }
void CORBAComponent::load ( Task askingNode)
virtual

Load the component.

Implements YACS::ENGINE::ComponentInstance.

Definition at line 101 of file CORBAComponent.cxx.

References _objComponent, DEBTRACE, YACS::ENGINE::ComponentInstance::getCompoName(), YACS::ENGINE::RuntimeSALOME::getOrb(), YACS::ENGINE::getSALOMERuntime(), orb, and p.

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

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

Definition at line 55 of file CORBAComponent.hxx.

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

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: