00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef __COLCOWS_NODE_IMPL_HH__
00029 #define __COLCOWS_NODE_IMPL_HH__
00030
00031
00032 #include "ColCOWS_Include.hh"
00033 #include "ColCOWS_Debug.hh"
00034 #include "ColCOWS_Corba.hh"
00035
00036
00037 __COLCOWS_BEGIN__
00038
00039
00040 std::ostream& operator <<(std::ostream& stream, const IdlWorkspaceDesc& wsdesc);
00041
00042 std::ostream& operator <<(std::ostream& stream, const IdlWorkspaceDescSeq& wsdesc_seq);
00043
00044
00045 std::ostream& operator <<(std::ostream& stream, const IdlNodeDesc& wsnode);
00046
00047 std::ostream& operator <<(std::ostream& stream, const IdlNodeDescSeq& wsnode_seq);
00048
00049
00050 std::ostream& operator <<(std::ostream& stream, const IdlObjectDesc& ref);
00051
00052 std::ostream& operator <<(std::ostream& stream, const IdlObjectDescSeq& ref_seq);
00053
00054
00055
00056
00057
00058 class Node;
00059
00060
00061
00062
00063
00064
00065
00066
00067 class NodeServant :
00068 public virtual POA_ColCOWS::NodeInterface,
00069 public virtual PortableServer::RefCountServantBase
00070 {
00071
00072
00073 friend class Node;
00074
00075
00076
00077 public:
00078
00079
00080 NodeServant();
00081
00082
00083 virtual ~NodeServant();
00084
00085 static NodeServant * New(const char* ws_id,
00086 const char* ws_kind,
00087 const char* node_kind,
00088 unsigned long num_node,
00089 unsigned long max_descendant,
00090 unsigned long nb_nodes,
00091 unsigned long num_father,
00092 CORBA::ORB_ptr orbp ) ;
00093
00094
00095
00096 public:
00097
00098
00099 virtual void printself(std::ostream & stream) const;
00100
00101
00102 friend std::ostream& operator <<(std::ostream& stream, const NodeServant& _this);
00103
00104
00105 inline void lockChildrenMutex() { pthread_mutex_lock(&_children_mut); }
00106
00107
00108 inline void unlockChildrenMutex() { pthread_mutex_unlock(&_children_mut); }
00109
00110
00111 inline void lockActivationMutex() { pthread_mutex_lock(&_activation_mut); }
00112
00113
00114 inline void unlockActivationMutex() { pthread_mutex_unlock(&_activation_mut); }
00115
00116 protected:
00117
00118
00119 void activate( ) ;
00120
00121
00122 void deactivate( ) ;
00123
00124
00125 unsigned long connect( const std::string & ws_id, const std::string & ws_kind, const std::string & nameservice_str) ;
00126
00127
00128 void disconnect( unsigned long num_connection ) ;
00129
00130
00131 void disconnectAll( ) ;
00132
00133
00134 bool registerToFather( unsigned long max_retry = 0 ) ;
00135
00136 private:
00137
00138
00139 long indexConnection( CORBA::ULong num_connection );
00140
00141
00142
00143 public:
00144
00145
00146 virtual void setWorkspace(const IdlWorkspaceDesc& ws_desc);
00147
00148
00149 virtual void setChildNode(const IdlNodeDesc& node_desc) throw (CorbaException) ;
00150
00151
00152
00153
00154 virtual CORBA::Boolean isActivated() throw (CorbaException) ;
00155
00156
00157 virtual CORBA::Boolean isReady() throw (CorbaException) ;
00158
00159
00160 virtual CORBA::Boolean isConnected( CORBA::ULong num_connection ) throw (CorbaException) ;
00161
00162
00163 virtual CORBA::ULong getNumConnection(const char* ws_id, const char * ws_kind ) throw (CorbaException) ;
00164
00165
00166 virtual void getCommonNumConnection( CORBA::ULong & num_connection_proposal )throw (CorbaException) ;
00167
00168
00169
00170
00171 virtual void getNode(CORBA::ULong num_node, IdlNodeDesc_out node_desc) throw (CorbaException) ;
00172
00173
00174 virtual void getWorkspace(IdlWorkspaceDesc_out ws_desc) throw (CorbaException) ;
00175
00176
00177 virtual void getRemoteWorkspace(CORBA::ULong num_connection, IdlWorkspaceDesc_out ws_desc) throw (CorbaException) ;
00178
00179
00180 virtual void setRemoteWorkspace(CORBA::ULong num_connection,
00181 const IdlWorkspaceDesc& ws_desc,
00182 CORBA::Boolean connection_initiator);
00183
00184
00185 virtual void releaseRemoteWorkspace( CORBA::ULong num_connection );
00186
00187
00188
00189 protected:
00190
00191
00192 IdlNodeDesc_var _my_node;
00193
00194 IdlNodeDesc_var _father_node;
00195
00196
00197 IdlNodeDescSeq_var _children_nodes;
00198
00199
00200 IdlWorkspaceDesc_var _local_workspace;
00201
00202 IdlWorkspaceDescSeq_var _remote_workspaces;
00203
00204
00205 protected:
00206
00207
00208 CORBA::ORB_ptr _orbp;
00209
00210
00211 CosNaming::NamingContext_var _naming_ctxt;
00212
00213
00214 PortableServer::POA_var _root_poa;
00215
00216
00217 PortableServer::POA_var _colcows_poa;
00218
00219
00220 PortableServer::POAManager_var _colcows_pman;
00221
00222
00223 bool _ready;
00224
00225
00226 bool _auto_activation;
00227
00228
00229 bool _registred_to_father;
00230
00231
00232 unsigned long _current_num_connection;
00233
00234
00235 pthread_mutex_t _children_mut;
00236
00237
00238 pthread_mutex_t _activation_mut;
00239
00240
00241 pthread_cond_t _activation_cond;
00242
00243
00244 Node * _colcows_node;
00245 };
00246
00247 __COLCOWS_END__
00248
00249 #endif
00250
00251
00252