Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PsKernelObjectAbstractFactory.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of openMask © INRIA, CNRS, Universite de Rennes 1 1993-2002, thereinafter the Software
00003  * 
00004  * The Software has been developped within the Siames Project. 
00005  * INRIA, the University of Rennes 1 and CNRS jointly hold intellectual property rights
00006  * 
00007  * The Software has been registered with the Agence pour la Protection des
00008  * Programmes (APP) under registration number IDDN.FR.001.510008.00.S.P.2001.000.41200
00009  *
00010  * This file may be distributed under the terms of the Q Public License
00011  * version 1.0 as defined by Trolltech AS of Norway and appearing in the file
00012  * LICENSE.QPL included in the packaging of this file.
00013  *
00014  * Licensees holding valid specific licenses issued by INRIA, CNRS or Université de Rennes 1 
00015  * for the software may use this file in accordance with that specific license 
00016  *
00017  */
00018 #ifndef PsKernelObjectAbstractFactoryHEADER
00019 #define PsKernelObjectAbstractFactoryHEADER
00020 
00021 class PsSimulatedObject;
00022 class PsDuplicatedObject;
00023 class PsController;
00024 class PsPolatorNT;
00025 class PsName;
00026 class PsKernelObjectClassicFactory;
00027 class PsKernelObjectMomeFactory;
00028 template <typename Type> class PsInputAlias;
00029 template <typename Type> class PsSensitiveInputAlias;
00030 template <typename Type> class PsSensitiveNotifyingInputAlias;
00031 template <typename Type> class PsOutputAlias;
00032 template <typename Type> class PsAbstractInput;
00033 template <typename Type> class PsInput;
00034 template <typename Type> class PsSensitiveInput;
00035 template <typename Type> class PsSensitiveNotifyingInput;
00036 template <typename Type> class PsOutput;
00037 template <typename Type> class PsMomeOutput;
00038 template <typename Type,class AncestorClass > class PsGenericControlParameter;
00039 template <typename Type> class PsControlParameter ;
00040 
00041 #include<iostream>
00043 class PsKernelObjectAbstractFactory {
00044 public:
00045   ~PsKernelObjectAbstractFactory();
00046   
00047   template <typename Type>
00048   PsInput<Type> * createInput(const PsName & name, 
00049                               PsSimulatedObject & owner,
00050                               bool makeConnectable,
00051                               int requestedPrecisionLevel) ;   
00052   template <typename Type>
00053   PsSensitiveInput<Type> * createSensitiveInput(const PsName & name, 
00054                                                 PsSimulatedObject & owner,
00055                                                 bool makeConnectable,
00056                                                 int requestedPrecisionLevel) ;   
00057    template <typename Type>
00058    PsSensitiveNotifyingInput<Type> * createSensitiveNotifyingInput(const PsName & name, 
00059                                                                     PsSimulatedObject & owner,
00060                                                                    bool makeConnectable,
00061                                                                    int requestedPrecisionLevel) ;   
00062    template <typename Type>
00063    PsOutput<Type> * createOutput(const PsName & name, 
00064                                 PsSimulatedObject & owner,
00065                                 int historyLength,
00066                                 PsPolatorNT * polator) ;
00067    template <typename Type>
00068    PsControlParameter<Type> * createControlParameter( const PsName & name, 
00069                                                       PsSimulatedObject & owner,
00070                                                       int historyLength,
00071                                                       PsPolatorNT * polator) ;
00072    template <typename Type>
00073    PsInputAlias<Type> * createInputAlias(const PsName & name, 
00074                                          PsSimulatedObject & owner,
00075                                          PsAbstractInput<Type> * input,
00076                                          int requestedPrecisionLevel) ;  
00077    template <typename Type>
00078    PsSensitiveInputAlias<Type> * createSensitiveInputAlias(const PsName & name, 
00079                                                            PsSimulatedObject & owner,
00080                                                            PsAbstractInput<Type> * input,
00081                                                            int requestedPrecisionLevel) ;  
00082    template <typename Type>
00083    PsSensitiveNotifyingInputAlias<Type> * 
00084    createSensitiveNotifyingInputAlias(const PsName & name, 
00085                                       PsSimulatedObject & owner,
00086                                       PsAbstractInput<Type> * input,
00087                                       int requestedPrecisionLevel) ;  
00088    template <typename Type>
00089    PsOutputAlias<Type> * createOutputAlias(const PsName & name, 
00090                                            PsSimulatedObject & owner,
00091                                            PsOutput<Type> * output,
00092                                            int historyLength,
00093                                            PsPolatorNT * polator);  
00094 protected:
00095    enum ConcreteFactory { CLASSIC , MOME };
00096    PsKernelObjectAbstractFactory(ConcreteFactory factoryType);
00097    PsKernelObjectClassicFactory * classicFactory;
00098    PsKernelObjectMomeFactory * momeFactory;
00099 private:
00100    ConcreteFactory myConcreteFactoryType;
00101 };   
00102 
00108 class PsKernelObjectClassicFactory : public PsKernelObjectAbstractFactory {
00109 public:
00110    PsKernelObjectClassicFactory();
00111    virtual ~PsKernelObjectClassicFactory();
00112 
00113    template <typename Type>
00114    PsInput<Type> * createInput(const PsName & name, 
00115                                PsSimulatedObject & owner,
00116                                bool makeConnectable,
00117                                int requestedPrecisionLevel) 
00118    {
00119       return new PsInput<Type>(name,owner,makeConnectable,requestedPrecisionLevel);
00120    }
00121    template <typename Type>
00122    PsSensitiveInput<Type> * createSensitiveInput(const PsName & name, 
00123                                                  PsSimulatedObject & owner,
00124                                                  bool makeConnectable,
00125                                                  int requestedPrecisionLevel) 
00126    {
00127       return new PsSensitiveInput<Type>(name,owner,makeConnectable,requestedPrecisionLevel);
00128    }
00129    template <typename Type>
00130    PsSensitiveNotifyingInput<Type> * 
00131    createSensitiveNotifyingInput(const PsName & name, 
00132                                  PsSimulatedObject & owner,
00133                                  bool makeConnectable,
00134                                  int requestedPrecisionLevel) 
00135    {
00136       return new PsSensitiveNotifyingInput<Type>(name,owner,makeConnectable,requestedPrecisionLevel);
00137    }
00138    template <typename Type>
00139    PsOutput<Type> * createOutput(const PsName & name, 
00140                                  PsSimulatedObject & owner,
00141                                  int historyLength,
00142                                  PsPolatorNT * polator) 
00143    {
00144       return new PsOutput<Type>(name,owner,historyLength,polator);
00145    }
00146       
00147    template <typename Type>
00148    PsControlParameter<Type> * createControlParameter(const PsName & name, 
00149                                                      PsSimulatedObject & owner,
00150                                                      int historyLength,
00151                                                      PsPolatorNT * polator) {
00152       return new PsGenericControlParameter<Type,PsOutput<Type> > (name,owner,historyLength,polator) ;
00153    }
00154 
00155 
00156   template <typename Type>
00157   PsInputAlias<Type> * createInputAlias(const PsName & name, 
00158                                         PsSimulatedObject & owner,
00159                                         PsAbstractInput<Type> * input,
00160                                         int requestedPrecisionLevel)  {
00161      return new PsInputAlias<Type>(name,owner,input,requestedPrecisionLevel);
00162   }
00163   template <typename Type>
00164   PsSensitiveInputAlias<Type> * createSensitiveInputAlias(const PsName & name, 
00165                                                           PsSimulatedObject & owner,
00166                                                           PsAbstractInput<Type> * input,
00167                                                           int requestedPrecisionLevel)  
00168    {
00169       return new PsSensitiveInputAlias<Type>(name,owner,input,requestedPrecisionLevel);
00170    }
00171   template <typename Type>
00172   PsSensitiveNotifyingInputAlias<Type> * createSensitiveNotifyingInputAlias(const PsName & name, 
00173                                                                             PsSimulatedObject & owner,
00174                                                                             PsAbstractInput<Type> * input,
00175                                                                             int requestedPrecisionLevel)  
00176    {
00177       return new PsSensitiveNotifyingInputAlias<Type>(name,owner,input,requestedPrecisionLevel);
00178    }
00179   
00180   template <typename Type>
00181   PsOutputAlias<Type> * createOutputAlias(const PsName & name, 
00182                                           PsSimulatedObject & owner,
00183                                           PsOutput<Type> * output, 
00184                                           int historyLength,
00185                                           PsPolatorNT * polator)  
00186    {
00187       return new PsOutputAlias<Type>(name,owner,output,historyLength,polator);
00188    }
00189   
00190 
00191 };   
00197 class PsKernelObjectMomeFactory : public PsKernelObjectAbstractFactory {
00198 public:
00199    PsKernelObjectMomeFactory();
00200    virtual ~PsKernelObjectMomeFactory();
00201 
00202    template <typename Type>
00203    PsInput<Type> * createInput(const PsName & name, 
00204                                PsSimulatedObject & owner,
00205                                bool makeConnectable,
00206                                int requestedPrecisionLevel) 
00207    {
00208       return new PsInput<Type>(name,owner,makeConnectable,requestedPrecisionLevel);
00209    }
00210    template <typename Type>
00211    PsSensitiveInput<Type> * createSensitiveInput(const PsName & name, 
00212                                                  PsSimulatedObject & owner,
00213                                                  bool makeConnectable,
00214                                                  int requestedPrecisionLevel) 
00215    {
00216       return new PsSensitiveInput<Type>(name,owner,makeConnectable, requestedPrecisionLevel);
00217    }
00218    template <typename Type>
00219    PsSensitiveNotifyingInput<Type> * 
00220    createSensitiveNotifyingInput(const PsName & name, 
00221                                  PsSimulatedObject & owner,
00222                                  bool makeConnectable,
00223                                  int requestedPrecisionLevel) 
00224    {
00225       return new PsSensitiveNotifyingInput<Type>(name,owner,makeConnectable,requestedPrecisionLevel);
00226    }
00227    template <typename Type>
00228    PsOutput<Type> * createOutput(const PsName & name, 
00229                                  PsSimulatedObject & owner,
00230                                  int historyLength,
00231                                  PsPolatorNT * polator) {
00232 #if defined(_MOME) || !defined(_SGI)
00233       //cout<<"création d'une output Mome"<<endl;
00234       return new PsMomeOutput<Type>(name,owner,historyLength,polator);
00235 #else
00236       return 0 ;
00237 #endif
00238    }
00239       
00240    template <typename Type>
00241    PsControlParameter<Type> * createControlParameter(const PsName & name, 
00242                                                      PsSimulatedObject & owner,
00243                                                      int historyLength,
00244                                                      PsPolatorNT * polator) 
00245    {
00246 #if defined(_MOME) || !defined(_SGI)
00247       return new PsGenericControlParameter<Type, PsMomeOutput<Type> >(name,owner,historyLength,polator);
00248 #else
00249       return 0 ;
00250 #endif
00251    }
00252 
00253 
00254   template <typename Type>
00255   PsInputAlias<Type> * createInputAlias(const PsName & name, 
00256                                         PsSimulatedObject & owner,
00257                                         PsAbstractInput<Type> * input,
00258                                         int requestedPrecisionLevel)  
00259    {
00260       return new PsInputAlias<Type>(name,owner,input,requestedPrecisionLevel);
00261    }
00262    template <typename Type>
00263    PsSensitiveInputAlias<Type> * createSensitiveInputAlias(const PsName & name, 
00264                                                            PsSimulatedObject & owner,
00265                                                            PsAbstractInput<Type> * input,
00266                                                            int requestedPrecisionLevel)  
00267    {
00268       return new PsSensitiveInputAlias<Type>(name,owner,input,requestedPrecisionLevel);
00269    }
00270    template <typename Type>
00271    PsSensitiveNotifyingInputAlias<Type> * createSensitiveNotifyingInputAlias(const PsName & name, 
00272                                                                              PsSimulatedObject & owner,
00273                                                                              PsAbstractInput<Type> * input,
00274                                                                              int requestedPrecisionLevel)  {
00275       return new PsSensitiveNotifyingInputAlias<Type>(name,owner,input,requestedPrecisionLevel);
00276   }
00277   
00278   template <typename Type>
00279   PsOutputAlias<Type> * createOutputAlias(const PsName & name, 
00280                                           PsSimulatedObject & owner,
00281                                           PsOutput<Type> * output, 
00282                                           int historyLength,
00283                                           PsPolatorNT * polator)  {
00284      return new PsOutputAlias<Type>(name,owner,output,historyLength,polator);
00285   }
00286   
00287 
00288 };   
00289 
00290 //------------------------ Mise en oeuvre -----------------------------
00291 
00292 template <typename Type>
00293 PsInput<Type> * PsKernelObjectAbstractFactory::createInput(const PsName & name, 
00294                                                            PsSimulatedObject & owner,
00295                                                            bool makeConnectable,
00296                                                            int requestedPrecisionLevel) 
00297 {
00298    switch(myConcreteFactoryType) {
00299    case CLASSIC:
00300       return classicFactory->template createInput<Type>(name,owner,makeConnectable,requestedPrecisionLevel);
00301    case MOME:
00302       return momeFactory->template createInput<Type>(name,owner,makeConnectable,requestedPrecisionLevel);
00303    default:
00304       PsController::error("KernelObjetcFactory de type inconnu");
00305       return NULL;
00306    }
00307 }
00308 
00309 template <typename Type>
00310 PsSensitiveInput<Type> * PsKernelObjectAbstractFactory::createSensitiveInput(const PsName & name, 
00311                                                                              PsSimulatedObject & owner,
00312                                                                              bool makeConnectable,
00313                                                                              int requestedPrecisionLevel) 
00314 {
00315    switch(myConcreteFactoryType) {
00316    case CLASSIC:
00317       return classicFactory->template createSensitiveInput<Type>(name,owner,makeConnectable,requestedPrecisionLevel);
00318    case MOME:
00319       return momeFactory->template createSensitiveInput<Type>(name,owner,makeConnectable,requestedPrecisionLevel);
00320    default:
00321       PsController::error("KernelObjetcFactory de type inconnu");
00322       return NULL;
00323    }
00324 }
00325 template <typename Type>
00326 PsSensitiveNotifyingInput<Type> * 
00327 PsKernelObjectAbstractFactory::createSensitiveNotifyingInput(const PsName & name, 
00328                                                              PsSimulatedObject & owner,
00329                                                              bool makeConnectable,
00330                                                              int requestedPrecisionLevel) 
00331 {
00332    switch(myConcreteFactoryType) {
00333    case CLASSIC:
00334       return classicFactory->template createSensitiveNotifyingInput<Type>(name,owner,makeConnectable,requestedPrecisionLevel);
00335    case MOME:
00336       return momeFactory->template createSensitiveNotifyingInput<Type>(name,owner,makeConnectable,requestedPrecisionLevel);
00337    default:
00338       PsController::error("KernelObjetcFactory de type inconnu");
00339       return NULL;
00340    }
00341 }
00342 
00343 template <typename Type>
00344 PsSensitiveInputAlias<Type> * 
00345 PsKernelObjectAbstractFactory::createSensitiveInputAlias(const PsName & name, 
00346                                                          PsSimulatedObject & owner,
00347                                                          PsAbstractInput<Type> * input,
00348                                                          int requestedPrecisionLevel) {
00349    switch(myConcreteFactoryType) {
00350    case CLASSIC:
00351       return classicFactory->template createSensitiveInputAlias<Type>(name,owner,input,requestedPrecisionLevel);
00352    case MOME:
00353       return momeFactory->template createSensitiveInputAlias<Type>(name,owner,input,requestedPrecisionLevel);
00354    default:
00355       PsController::error("KernelObjetcFactory de type inconnu");
00356       return NULL;
00357    }
00358 }
00359 template <typename Type>
00360 PsSensitiveNotifyingInputAlias<Type> * 
00361 PsKernelObjectAbstractFactory::createSensitiveNotifyingInputAlias(const PsName & name, 
00362                                                                   PsSimulatedObject & owner,
00363                                                                   PsAbstractInput<Type> * input,
00364                                                                   int requestedPrecisionLevel) 
00365 {
00366    switch(myConcreteFactoryType) {
00367    case CLASSIC:
00368       return classicFactory->template createSensitiveNotifyingInputAlias<Type>(name,owner,input,requestedPrecisionLevel);
00369    case MOME:
00370       return momeFactory->template createSensitiveNotifyingInputAlias<Type>(name,owner,input,requestedPrecisionLevel);
00371    default:
00372       PsController::error("KernelObjetcFactory de type inconnu");
00373       return NULL;
00374    }
00375 }
00376 
00377 //                          -------------
00378 
00379 template <typename Type>
00380 PsOutput<Type> * PsKernelObjectAbstractFactory::createOutput(const PsName & name, 
00381                                                              PsSimulatedObject & owner,
00382                                                              const int historyLength,
00383                                                              PsPolatorNT * polator) 
00384 {
00385    switch(myConcreteFactoryType) {
00386    case CLASSIC:
00387       return classicFactory->template createOutput<Type>(name,owner,historyLength,polator);
00388    case MOME:
00389       return momeFactory->template createOutput<Type>(name,owner,historyLength,polator);
00390    default:
00391       PsController::error("KernelObjetcFactory de type inconnu");
00392       return NULL;
00393    }
00394 }
00395 
00396 //                          -------------
00397 
00398 template <typename Type>
00399 PsControlParameter<Type> * PsKernelObjectAbstractFactory::createControlParameter(const PsName & name, 
00400                                                                                  PsSimulatedObject & owner,
00401                                                                                  int historyLength,
00402                                                                                  PsPolatorNT * polator)
00403 {
00404    switch(myConcreteFactoryType) {
00405    case CLASSIC:
00406       return classicFactory->template createControlParameter<Type>(name,owner, historyLength, polator);
00407    case MOME:
00408       return momeFactory->template createControlParameter<Type>(name,owner, historyLength, polator);
00409    default:
00410       PsController::error("KernelObjetcFactory de type inconnu");
00411       return NULL;
00412    }
00413 }
00414 
00415 //                          -------------
00416 
00417 
00418 template <typename Type>
00419 PsInputAlias<Type> * PsKernelObjectAbstractFactory::createInputAlias(const PsName & name, 
00420                                                                      PsSimulatedObject & owner,
00421                                                                      PsAbstractInput<Type> * input,
00422                                                                      int requestedPrecisionLevel)   
00423 { 
00424   switch(myConcreteFactoryType) {
00425   case CLASSIC:
00426     return classicFactory->template createInputAlias<Type>(name,owner,input,requestedPrecisionLevel);
00427   case MOME:
00428     return momeFactory->template createInputAlias<Type>(name,owner,input,requestedPrecisionLevel);
00429   default:
00430     PsController::error("KernelObjetcFactory de type inconnu");
00431     return NULL;
00432   }   
00433 }
00434 
00435 template <typename Type>
00436 PsOutputAlias<Type> * PsKernelObjectAbstractFactory::createOutputAlias(const PsName & name, 
00437                                                                        PsSimulatedObject & owner,
00438                                                                        PsOutput<Type> * output,
00439                                                                        int historyLength,
00440                                                                        PsPolatorNT * polator)   
00441 { 
00442   switch(myConcreteFactoryType) {
00443   case CLASSIC:
00444     return classicFactory->template createOutputAlias<Type>(name,owner,output,historyLength,polator);
00445   case MOME:
00446     return momeFactory->template createOutputAlias<Type>(name,owner,output,historyLength,polator);
00447   default:
00448     PsController::error("KernelObjetcFactory de type inconnu");
00449     return NULL;
00450   }   
00451 }
00452 #endif

logo OpenMask

Documentation generated on Mon Nov 25 15:25:00 2002

Generated with doxygen 1.2.12 by Dimitri van Heesch ,   1997-2001