CCAFFEINE
0.8.8
|
00001 #ifndef __GIZZARD_H__ 00002 #define __GIZZARD_H__ 00003 00004 #include <map> 00005 #include <string> 00006 #include <vector> 00007 00008 00009 00010 00011 class OpqParameterPortFactory; 00012 class OpqConnectionEventService; 00013 00015 class Gizzard : public virtual ::ccafeopq::Services, 00016 public virtual KernelPort 00017 { 00018 00019 private: 00020 static bool countInitDone; 00021 static int pnameCount; 00022 00023 00025 bool debug; 00026 00032 ::ccafeopq::ComponentID_shared cid; 00033 00034 00035 // provides ports 00036 ::std::vector< ProviderPortData > pData; 00037 // uses ports, connected or not 00038 ::std::vector< UserPortData > uData; 00039 // provided-port connections. 00040 ::std::vector< ConnectionID_ptr > cData; 00041 int serial; 00042 int nextSerial(); 00043 00044 00046 int findIndex( ::std::vector< ProviderPortData > & info, const std::string & name); 00047 00049 int findIndex( ::std::vector< UserPortData > & info, const std::string & name); 00050 00051 int getNextCount(); 00052 00053 ::ccafeopq::TypeMap_shared compPropertyMap; 00054 00055 int64_t fortranMPIComm; 00056 bool hasComm; 00057 00058 public: 00062 Gizzard(const std::string & instanceName, int64_t fComm, bool useComm); 00063 00064 virtual ~Gizzard(); 00065 00067 void dbug(bool tf) { 00068 debug = tf; 00069 } 00070 00071 00076 virtual void registerUsesPort(ccafeopq::PortInfo * pInfo) throw 00077 (ccafeopq::Exception); 00078 00079 virtual void registerUsesPort(const ::std::string & pName, const ::std::string & pType, ::ccafeopq::TypeMap_shared props) throw ( ::ccafeopq::Exception ); 00080 00082 virtual void addProvidesPort(ccafeopq::Port * inPort, 00083 ccafeopq::PortInfo * name) throw (ccafeopq::Exception); 00084 00085 00088 ::ccafeopq::Port * getOpaquePort(const char* name, enum ccafeopq::ExceptionType &status); 00089 ::ccafeopq::Port * getOpaquePort(const ::std::string & name, enum ccafeopq::ExceptionType &status); 00090 00093 ::ccafeopq::Port * getPort(const std::string & name, enum ccafeopq::ExceptionType &status) throw (ccafeopq::Exception); 00094 00095 00097 virtual void releasePort(char *name); 00099 virtual void releasePort(const std::string & name) throw (ccafeopq::Exception); 00101 virtual void releasePort(const char *name); 00102 00103 00105 virtual ccafeopq::PortInfo * 00106 createPortInfo(const std::string & name, const std::string & type, 00107 const std::map<std::string, std::string> & properties) 00108 throw (ccafeopq::Exception); 00109 00112 virtual void destroyPortInfo(ccafeopq::PortInfo * pi); 00113 00115 virtual const char* getComponentInstanceName(); 00116 00118 ::ccafeopq::ComponentID_shared getComponentID(); 00119 00121 virtual void destroyComponentID( ::ccafeopq::ComponentID_shared cid_); 00122 00123 virtual void addProvidesPort(ccafeopq::Port*, const std::string& pname, const std::string& ptype, ::ccafeopq::TypeMap_shared t) throw ( ::ccafeopq::Exception ); 00124 00125 virtual void addProvidesPort(ccafeopq::Port*, const std::string& pname, const std::string& ptype) throw ( ::ccafeopq::Exception ); 00126 00127 static ::ccafeopq::TypeMap_shared createTypeMapStatic() throw ( ::ccafeopq::Exception ); 00128 00129 virtual ::ccafeopq::TypeMap_shared createTypeMap() throw ( ::ccafeopq::Exception ); 00130 00131 virtual ::ccafeopq::TypeMap_shared getPortProperties(const ::std::string& Name) throw ( ::ccafeopq::Exception ); 00132 00133 virtual void setPortProperties(const ::std::string& Name, ::ccafeopq::TypeMap_shared tm) throw ( ::ccafeopq::Exception ); 00134 00135 virtual ::std::string genUniquePortName(const ::std::string& baseName) throw ( ::ccafeopq::Exception ); 00136 00138 ::ccafeopq::TypeMap_shared getPropertyMap(); 00139 00141 void setPropertyMapData( ::ccafeopq::TypeMap_shared tm ); 00142 00143 00144 // Below here these methods are unavailable to the a component 00145 // contained by our framework. 00146 00149 int connectUsesPort(::ccafeopq::PortInfo *info, 00150 ::ccafeopq::Port *up, 00151 ::ccafeopq::PortInfo *fromPI, 00152 Gizzard *fromG); 00154 int connectUsesPort(const ::std::string & userPortName, 00155 ::ccafeopq::Port *up, 00156 const ::std::string &providerPortName, 00157 Gizzard *fromG); 00158 00159 // for internal (fwk) connections only. 00160 int connectUsesPort(const ::std::string & pName, ::ccafeopq::Port *up); 00161 00162 00165 int disconnectProvidesPort(ConnectionID_ptr c); 00166 //int disconnectProvidesPort(Connection* c); 00167 00169 int connectProvidesPort(ConnectionID_ptr c); 00170 //int connectProvidesPort(Connection * c); 00171 00173 ::std::vector< ConnectionID_ptr > getConnections(); 00174 00176 ::std::vector< ConnectionID_ptr > getUsesConnections(); 00177 00179 int disconnectAllUsesPorts(); 00180 00188 int disconnectUsesPort(int pindex); 00189 00194 const ::std::vector< UserPortData > & getUsesPortRegister(); 00195 00198 virtual int unregisterUsesPort(const char * name); 00201 virtual void unregisterUsesPort(const std::string & name) throw (ccafeopq::Exception); 00204 virtual int unregisterUsesPort(char *name); 00205 00208 virtual ::ccafeopq::Port * removeProvidesPort(const char * name); 00209 00210 00213 virtual ::ccafeopq::Port * removeProvidesPort(const std::string & name) throw (ccafeopq::Exception); 00214 00215 bool usesThisPortType(const std::string& typeToTest); 00216 bool providesThisPortType(const std::string& typeToTest); 00217 00218 ::std::vector< ::std::string > getUsesPortTypes(); 00219 ::std::vector< ::std::string > getUsesPortNames(); 00220 ::std::vector< ::std::string > getProvidesPortTypes(); 00221 ::std::vector< ::std::string > getProvidesPortNames(); 00222 00225 virtual const ::std::vector< UserPortData > & getUsesPorts(); 00226 00228 virtual const ::std::vector< ProviderPortData > & getProvidesPorts(); 00229 00238 ::std::vector< ::std::string> getConnectionStrings(); 00239 00240 OpqConnectionEventService * getOCES(); 00241 00242 private: 00243 OpqParameterPortFactory *oppf; // very lightweight 00244 OpqConnectionEventService *oces; // very lightweight 00245 00246 00247 // most of the guts of checkInternalServices are now part of the binding. 00248 // the kernel is getting smaller and less tangled with legacy code. 00249 // addServicesHelper and the bindings now take care of binding- 00250 // specific special ports. 00251 void checkInternalServices(const ::std::string & name, const ::std::string & type); 00252 00253 ::ccafeopq::SvcPortMap opaqueDelegates; 00254 ::std::vector< ::ccafeopq::ServicesHelper * > helpers; 00255 00256 public: 00257 void initDelegates(); 00258 00260 void addServicesHelper( ::ccafeopq::ServicesHelper *sh); 00261 00262 00263 public: 00264 virtual void addComponentChangedListener(ComponentChangedListener* l) ; 00265 void fireComponentChangedEvent(ComponentChangedEvent* evt) ; 00266 00267 void setFrameData(std::map<std::string, void *> *fd); 00268 00269 /* basically this is only here for ServicesHelper implementations. */ 00270 ::ccafeopq::TypeMap_shared getComponentInternalPropertyMap(); 00271 00272 bool hasMPIComm(int64_t & fortranBorrowComm) ; 00273 private: 00275 ::std::vector< ComponentChangedListener * > cmptChgLsnrs; 00276 00277 private: 00278 00283 ::std::map<std::string, void *> *frame; 00284 00285 00286 }; 00287 00288 #endif //__GIZZARD_H__