public Boolean TryToSet(IGlobalElement globalFunction, ILogBuilder log)
 {
     if (globalFunction is IGlobalElementWithSharedData sharedFunction)
     {
         String fn = sharedFunction.GetType().Name;
         if (!storage.ContainsKey(fn))
         {
             storage.Add(fn, sharedFunction.GetSharedDataStructure());
             log.log(":: Function [" + fn + "] stored data into shared pool");
             return(true);
         }
     }
     return(false);
 }
 public Boolean TryToGet(IGlobalElement globalFunction, ILogBuilder log)
 {
     if (globalFunction is IGlobalElementWithSharedData sharedFunction)
     {
         String fn = sharedFunction.GetType().Name;
         if (storage.ContainsKey(fn))
         {
             sharedFunction.SetSharedDataStructure(storage[fn]);
             log.log(":: Function [" + fn + "] retrieved data from the shared pool");
             return(true);
         }
     }
     return(false);
 }
예제 #3
0
        /// <summary>
        /// Creates instance of a global function
        /// </summary>
        /// <returns></returns>
        public IGlobalElement GetFunction(ILogBuilder logger)
        {
            if (functionName == "0")
            {
            }

            IGlobalElement output = null;

            var t = TypeProviders.GlobalTermFunction.GetTypeByName(functionName);

            if (t != null)
            {
                output = TypeProviders.GlobalTermFunction.GetInstance(functionName);
                if (output == null)
                {
                    throw new Exception("Global element function [" + functionName + "] was not found by the TypeProviders.GlobalTermFunction!");
                }

                if (output is CollectionTDPElement tdpElement)
                {
                    //tdpElement.

                    //  logger.log("Created: TDP function based on [" + tdpFactor.ToString() + "] factor");
                }
                else if (output is IDFElement idfElement)
                {
                    //  idfElement.Computation = imbEnumExtendBase.GetEnumFromStringFlags<IDFComputation>(flags).FirstOrDefault();
                    //  logger.log("Created: IDF function based on [" + output.idfComputation.ToString() + "] computation");
                }
                else if (output is IGMElement igmElement)
                {
                    igmElement.l = l;
                    logger.log("Created: IGM function with landa set to [" + l.ToString() + "]");
                }
                else if (output is ICSdFElement icsdElement)
                {
                    logger.log("Created: ICSd function");
                }
                else if (output is CWPElement cwpElement)
                {
                }


                output.DeploySettings(this);
            }



            /*
             * GlobalElementBase output = null;
             * switch (functionType)
             * {
             *  case GlobalFunctionType.ICF:
             *      output = new ICFElement();
             *      break;
             *  case GlobalFunctionType.ICSdF:
             *      output = new ICSdFElement();
             *      break;
             *  default:
             *  case GlobalFunctionType.IDF:
             *      IDFElement iDFElement = new IDFElement();
             *      iDFElement.Computation = idfComputation;
             *      output = iDFElement;
             *      break;
             *  case GlobalFunctionType.IGM:
             *      IGMElement iGMElement = new IGMElement();
             *      iGMElement.l = l;
             *      output = iGMElement;
             *      break;
             *  case GlobalFunctionType.TDP:
             *      CollectionTDPElement tDP = new CollectionTDPElement();
             *      tDP.factor = tdpFactor;
             *      output = tDP;
             *      break;
             * }
             */

            return(output);
        }