// Path: src/main/java/org/logic2j/core/api/library/PLibrary.java
// public interface PLibrary {
// 
//   String NO_DIRECT_INVOCATION_USE_REFLECTION = "no-direct-invocation-use-reflection";
// 
//   /**
//    * The dispatcher allow direct invocation of the primitives, without the need for reflection,
//    * for performance reasons.
//    *
//    * @param theMethodName
//    * @param theGoalStruct
//    * @param currentVars
//    * @return
//    */
//   Object dispatch(String theMethodName, Struct<?> theGoalStruct, UnifyContext currentVars);
// 
// }
// 
// Path: src/main/java/org/logic2j/core/impl/PrologImplementation.java
// public interface PrologImplementation extends Prolog {
// 
//   // ---------------------------------------------------------------------------
//   // Accessors to the sub-features of the Prolog engine
//   // ---------------------------------------------------------------------------
// 
//   /**
//    * @return The implementation for managing libraries.
//    */
//   LibraryManager getLibraryManager();
// 
//   /**
//    * @return The implementation of inference logic.
//    */
//   Solver getSolver();
// 
//   /**
//    * @return The implementation for managing operators.
//    */
//   OperatorManager getOperatorManager();
// 
//   /**
//    * @return Marshalling
//    */
//   TermMarshaller getTermMarshaller();
// 
//   TermUnmarshaller getTermUnmarshaller();
// 
//   void setTermAdapter(TermAdapter termAdapter);
// 
// }


import org.logic2j.core.api.library.PLibrary;
import org.logic2j.core.impl.PrologImplementation;
import org.logic2j.engine.exception.InvalidTermException;
import org.logic2j.engine.model.Struct;
import org.logic2j.engine.model.Var;
import org.logic2j.engine.solver.Continuation;
import org.logic2j.engine.solver.listener.SolutionListener;
import org.logic2j.engine.unify.UnifyContext;
/*
 * logic2j - "Bring Logic to your Java" - Copyright (c) 2017 Laurent.Tettoni@gmail.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Foobar is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser Public License for more details.
 *
 * You should have received a copy of the GNU Lesser Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.logic2j.core.library.impl;


/**
 * Base class for libraries, provides convenience methods to unify, deunify, and access the underlying {@link PrologImplementation}
 * features.
 */
public class LibraryBase implements PLibrary {
  private final PrologImplementation prolog;

  public LibraryBase(PrologImplementation theProlog) {
    this.prolog = theProlog;
  }

  /**
   * Direct dispatch to avoid reflective invocation using Method.invoke() due to performance reasons.
   * You MAY override this method, if you don't, reflection will be used instead at a little performance cost.
   * <p/>
   * TODO Document example of typical overriding of dispatch()
   *
   * @param theMethodName The name of the method, internalized using {@link String#intern()} so you can use ==
   * @param theGoalStruct Regular argument for invoking a primitive
   * @param currentVars   Regular argument for invoking a primitive
   */
// Path: src/main/java/org/logic2j/core/api/library/PLibrary.java
// public interface PLibrary {
// 
//   String NO_DIRECT_INVOCATION_USE_REFLECTION = "no-direct-invocation-use-reflection";
// 
//   /**
//    * The dispatcher allow direct invocation of the primitives, without the need for reflection,
//    * for performance reasons.
//    *
//    * @param theMethodName
//    * @param theGoalStruct
//    * @param currentVars
//    * @return
//    */
//   Object dispatch(String theMethodName, Struct<?> theGoalStruct, UnifyContext currentVars);
// 
// }
// 
// Path: src/main/java/org/logic2j/core/impl/PrologImplementation.java
// public interface PrologImplementation extends Prolog {
// 
//   // ---------------------------------------------------------------------------
//   // Accessors to the sub-features of the Prolog engine
//   // ---------------------------------------------------------------------------
// 
//   /**
//    * @return The implementation for managing libraries.
//    */
//   LibraryManager getLibraryManager();
// 
//   /**
//    * @return The implementation of inference logic.
//    */
//   Solver getSolver();
// 
//   /**
//    * @return The implementation for managing operators.
//    */
//   OperatorManager getOperatorManager();
// 
//   /**
//    * @return Marshalling
//    */
//   TermMarshaller getTermMarshaller();
// 
//   TermUnmarshaller getTermUnmarshaller();
// 
//   void setTermAdapter(TermAdapter termAdapter);
// 
// }


// Path: src/main/java/org/logic2j/core/library/impl/LibraryBase.java
import org.logic2j.core.api.library.PLibrary;
import org.logic2j.core.impl.PrologImplementation;
import org.logic2j.engine.exception.InvalidTermException;
import org.logic2j.engine.model.Struct;
import org.logic2j.engine.model.Var;
import org.logic2j.engine.solver.Continuation;
import org.logic2j.engine.solver.listener.SolutionListener;
import org.logic2j.engine.unify.UnifyContext;

/*
 * logic2j - "Bring Logic to your Java" - Copyright (c) 2017 Laurent.Tettoni@gmail.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Foobar is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser Public License for more details.
 *
 * You should have received a copy of the GNU Lesser Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.logic2j.core.library.impl;


/**
 * Base class for libraries, provides convenience methods to unify, deunify, and access the underlying {@link PrologImplementation}
 * features.
 */
public class LibraryBase implements PLibrary {
  private final PrologImplementation prolog;

  public LibraryBase(PrologImplementation theProlog) {
    this.prolog = theProlog;
  }

  /**
   * Direct dispatch to avoid reflective invocation using Method.invoke() due to performance reasons.
   * You MAY override this method, if you don't, reflection will be used instead at a little performance cost.
   * <p/>
   * TODO Document example of typical overriding of dispatch()
   *
   * @param theMethodName The name of the method, internalized using {@link String#intern()} so you can use ==
   * @param theGoalStruct Regular argument for invoking a primitive
   * @param currentVars   Regular argument for invoking a primitive
   */
  @Override