예제 #1
0
        public PqaEngine CreateCpuEngine(out PqaError err, EngineDefinition engDef)
        {
            if (engDef.AnswerCount == null || engDef.QuestionCount == null || engDef.TargetCount == null)
            {
                throw new PqaException("Answer, question and target counts must be all set.");
            }
            CiEngineDefinition ciEngDef = new CiEngineDefinition()
            {
                _nAnswers        = engDef.AnswerCount.Value,
                _nQuestions      = engDef.QuestionCount.Value,
                _nTargets        = engDef.TargetCount.Value,
                _precType        = (byte)engDef.PrecType,
                _precExponent    = engDef.PrecExponent,
                _precMantissa    = engDef.PrecMantissa,
                _initAmount      = engDef.InitAmount,
                _memPoolMaxBytes = engDef.MemPoolMaxBytes
            };
            IntPtr nativeEngine;
            IntPtr nativeError = IntPtr.Zero;

            try
            {
                nativeEngine = PqaEngineFactory_CreateCpuEngine(_nativeFactory, ref nativeError, ref ciEngDef);
            }
            finally
            {
                err = PqaError.Factor(nativeError);
            }
            if (nativeEngine == IntPtr.Zero)
            {
                return(null);
            }
            return(new PqaEngine(nativeEngine));
        }
예제 #2
0
 private static extern IntPtr PqaEngineFactory_CreateCpuEngine(IntPtr pFactory, ref IntPtr ppError,
                                                               ref CiEngineDefinition pEngDef);