00001 //===========================================================================// 00002 // 00003 // Description: interface for user defined event handling classes 00004 // Filename: colcows/ColCOWS_NodeDesc.hh 00005 // Authors: Michael Dussere and Aurélien Esnard 00006 // 00007 //===========================================================================// 00008 // 00009 // Copyright (C) 2003 INRIA and CNRS 00010 // 00011 // This library is free software; you can redistribute it and/or 00012 // modify it under the terms of the GNU Lesser General Public 00013 // License as published by the Free Software Foundation; either 00014 // version 2.1 of the License, or (at your option) any later version. 00015 // 00016 // This library is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 // Lesser General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU Lesser General Public 00022 // License along with this library; if not, write to the Free Software 00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00024 // 00025 //===========================================================================// 00026 00027 #ifndef __COLCOWS_NODE_DESC_HH__ 00028 #define __COLCOWS_NODE_DESC_HH__ 00029 00030 //---------------------------------------------------------------------------// 00031 #include "ColCOWS_Include.hh" 00032 #include "ColCOWS_Debug.hh" 00033 #include "ColCOWS_ObjectDesc.hh" 00034 //---------------------------------------------------------------------------// 00035 00036 namespace ColCOWS { 00037 struct IdlNodeDesc; 00038 }; 00039 00040 00041 __COLCOWS_BEGIN__ 00042 00043 //! Node Description 00044 /** 00045 * Unlike the IDL description, the class NodeDesc does'nt contain the hierarchy of the node. 00046 */ 00047 class NodeDesc : public std::map<std::string, ObjectDesc> 00048 { 00049 00050 //================================================// 00051 //=========== class standard interface ===========// 00052 public: 00053 //! constructor 00054 NodeDesc():_activated(false){} 00055 00056 //! idl constructor 00057 NodeDesc( const IdlNodeDesc & idl_node_desc ) { convertFromIdl( idl_node_desc );} 00058 00059 //! destructor 00060 virtual ~NodeDesc() {} 00061 00062 //! print self 00063 virtual void printself(std::ostream & stream, int indent = 0) const; 00064 00065 //=========================================// 00066 //=========== public interface ===========// 00067 public: 00068 00069 //! get a vector of object descriptions on the node 00070 void getObjectDescVec( ExtObjectDescVec & object_desc_vec, 00071 std::string obj_id = "", 00072 std::string obj_kind = "" ) const ; 00073 00074 //! idl import 00075 /** This method build the node description according to an IDL description. 00076 Unlike the IDL description, the class NodeDesc does'nt contain the hierarchy of the node **/ 00077 void convertFromIdl( const IdlNodeDesc & idl_node_desc ); 00078 00079 //! idl export 00080 /** This method build an IDL description according to the class NodeDesc. 00081 Unlike the IDL description, the class NodeDesc does'nt contain the hierarchy of the node **/ 00082 void convertToIdl(IdlNodeDesc & idl_node_desc) const; 00083 00084 //! update idl description 00085 /** This method update the listof the CORBA objects in th IDL description according to the class NodeDesc. 00086 Unlike the IDL description, the class NodeDesc does'nt contain the hierarchy of the node **/ 00087 void updateIdl( IdlNodeDesc & idl_node_desc ) const; 00088 00089 //! set a reference for this node 00090 void addReference( std::string obj_id, std::string obj_kind, CORBA::Object * ref) ; 00091 00092 //! get a reference from this node 00093 CORBA::Object * getReference( std::string obj_id ) const ; 00094 00095 //! clear all the references of this node 00096 void clearReferences( ) ; 00097 00098 //=========== Accessors ===========// 00099 public: 00100 //! get node kind 00101 inline std::string getKind() const { return _node_kind; } 00102 //! set node kind 00103 inline void setKind(std::string node_kind) { _node_kind = node_kind; } 00104 00105 //! get node number 00106 inline unsigned long getNumNode() const { return _num_node; } 00107 //! set node number 00108 inline void setNumNode(unsigned long num_node) { _num_node = num_node; } 00109 00110 //! get max node number of the descendants 00111 inline unsigned long getMaxDescendant() const { return _max_descendant; } 00112 //! set max node number of the descendants 00113 inline void setMaxDescendant(unsigned long max_descendant) { _max_descendant = max_descendant; } 00114 00115 //! get activated 00116 inline bool getActivated() const { return _activated; } 00117 //! set activated 00118 inline void setActivated(bool activated) { _activated = activated; } 00119 00120 protected: 00121 00122 //! Kind of the Workspace node ("proxy", "node", "master" ...) 00123 std::string _node_kind; 00124 00125 //! Number of the node among the node hierarchy 00126 unsigned long _num_node; 00127 00128 //! Max number of its descendants among the node hierarchy 00129 unsigned long _max_descendant; 00130 00131 //! Is the node activated 00132 bool _activated; 00133 00134 }; 00135 00136 //------------------------------------------------------------------------// 00137 00138 //! standard output stream operator 00139 inline std::ostream & operator <<(std::ostream & stream, const NodeDesc & _this) 00140 { 00141 stream << "NodeDesc { " << std::endl; 00142 _this.printself(stream); 00143 stream << "}" << std::flush; 00144 return stream; 00145 } 00146 00147 __COLCOWS_END__ 00148 00149 #endif // __COLCOWS_NODE_DESC_HH__ 00150 00151 // EOF 00152