// 
// File:          Minsurf_Component_Impl.hh
// Symbol:        Minsurf.Component-v0.0.3
// Symbol Type:   class
// Babel Version: 0.10.2
// Description:   Server-side implementation for Minsurf.Component
// 
// WARNING: Automatically generated; only changes within splicers preserved
// 
// babel-version = 0.10.2
// 

#ifndef included_Minsurf_Component_Impl_hh
#define included_Minsurf_Component_Impl_hh

#ifndef included_sidl_cxx_hh
#include "sidl_cxx.hh"
#endif
#ifndef included_Minsurf_Component_IOR_h
#include "Minsurf_Component_IOR.h"
#endif
// 
// Includes for all method dependencies.
// 
#ifndef included_Minsurf_Component_hh
#include "Minsurf_Component.hh"
#endif
#ifndef included_gov_cca_CCAException_hh
#include "gov_cca_CCAException.hh"
#endif
#ifndef included_gov_cca_Services_hh
#include "gov_cca_Services.hh"
#endif
#ifndef included_sidl_BaseInterface_hh
#include "sidl_BaseInterface.hh"
#endif
#ifndef included_sidl_ClassInfo_hh
#include "sidl_ClassInfo.hh"
#endif


// DO-NOT-DELETE splicer.begin(Minsurf.Component._includes)
// Put additional includes or other arbitrary code here...
// DO-NOT-DELETE splicer.end(Minsurf.Component._includes)

namespace Minsurf { 

  /**
   * Symbol "Minsurf.Component" (version 0.0.3)
   */
  class Component_impl
  // DO-NOT-DELETE splicer.begin(Minsurf.Component._inherits)
  // Put additional inheritance here...
  // DO-NOT-DELETE splicer.end(Minsurf.Component._inherits)
  {

  private:
    // Pointer back to IOR.
    // Use this to dispatch back through IOR vtable.
    Component self;

    // DO-NOT-DELETE splicer.begin(Minsurf.Component._implementation)
        gov::cca::TypeMap myTypeMap;
    gov::cca::Services myServices;

    double *bottom, *top, *left, *right;
    int  mx,my; // global dimension in each direction of the array
    int  bmx, bmy; // bounds
    double bheight;
    int n_iters;
    double fvalue;

    int MSA_BoundaryConditions(); // Calculate boundary conditions
    
    // Put additional implementation details here...
    // DO-NOT-DELETE splicer.end(Minsurf.Component._implementation)

  private:
    // private default constructor (required)
    Component_impl() 
    {} 

  public:
    // sidl constructor (required)
    // Note: alternate Skel constructor doesn't call addref()
    // (fixes bug #275)
    Component_impl( struct Minsurf_Component__object * s ) : self(s,
      true) { _ctor(); }

    // user defined construction
    void _ctor();

    // virtual destructor (required)
    virtual ~Component_impl() { _dtor(); }

    // user defined destruction
    void _dtor();

    // static class initializer
    static void _load();

  public:


    /**
     * Optional --
     * initialize() will be called from the Optimization Solver 
     * before solving in order to set up any data.
     */
    int32_t
    initialize() throw () 
    ;

    /**
     * Optional --
     * finalize() will be called from the Opimization Solver
     * when it through using the model (ie, when solver is deleted)
     */
    int32_t
    finalize() throw () 
    ;

    /**
     * Required --
     * getNumberVariables()  lets the Optimization Solver know how much 
     * space to allocate for the various vectors and matrices.
     */
    int32_t
    getNumberVariables() throw () 
    ;

    /**
     * Required --
     * evaluateObjectiveFunction(...) should be straightforward.
     * If you wish to only implement evaluateObjectiveAndGradient(), then
     * this function should allocate a dummy gradient vector and call
     * evaluateObjectiveAndGradient() explicitly.
     */
    void
    evaluateObjectiveFunction (
      /* in */ ::sidl::array<double> x,
      /* out */ double& f
    )
    throw () 
    ;


    /**
     * Required --
     * evaluateGradient(...) should be straightforward.
     * If you wish to only implement evaluateObjectiveAndGradient(), then
     * this function should call it explicitly. 
     */
    void
    evaluateGradient (
      /* in */ ::sidl::array<double> x,
      /* in */ ::sidl::array<double> g
    )
    throw () 
    ;


    /**
     * Required --
     * evaluateObjectiveAndGradient(...) should be straightforward.
     * If you wish to implement the function and gradient evaluation routines
     * separately, then this method should do so explicitly.
     */
    void
    evaluateObjectiveAndGradient (
      /* in */ ::sidl::array<double> x,
      /* out */ double& f,
      /* in */ ::sidl::array<double> g
    )
    throw () 
    ;


    /**
     * Optional --
     * evaluateHessian() is only necessary if using second derivative methods for
     * solving the model. 
     */
    void
    evaluateHessian (
      /* in */ ::sidl::array<double> x,
      /* in */ ::sidl::array<double> H
    )
    throw () 
    ;


    /**
     * Optional -- Used only by LMVM and BLMVM solvers with the right option is set.
     * hessianSolve(...) solve linear system involved exact or approximate Hessian.
     */
    void
    hessianSolve (
      /* in */ ::sidl::array<double> v,
      /* in */ ::sidl::array<double> w
    )
    throw () 
    ;

    /**
     * user defined non-static method.
     */
    void
    hessianSolve2 (
      /* in */ ::sidl::array<double> x,
      /* in */ ::sidl::array<double> v,
      /* in */ ::sidl::array<double> w
    )
    throw () 
    ;


    /**
     * Optional --
     * getVariableBounds() is only necessary if any of the variable bounds are 
     * not at (-inf, inf).    If a solution method
     * is selected that does not use variable bounds, then this function
     * will not be called.
     */
    void
    getVariableBounds (
      /* in */ ::sidl::array<double> xl,
      /* in */ ::sidl::array<double> xu
    )
    throw () 
    ;


    /**
     * Optional --
     * initializeVariables() is called from the Optimization Solver to
     * sets the solution vector to an initial value.
     */
    void
    initializeVariables (
      /* in */ ::sidl::array<double> x
    )
    throw () 
    ;


    /**
     * Optional --
     * monitor() is called from TAO at every iteration.
     * If the application programmer wants to perform some kind of
     * visualization or other output throughout the solve, then this
     * method should be implemented.
     */
    void
    monitor() throw () 
    ;

    /**
     * Optional --
     * checkConvergence() is called from TAO at every iteration.
     * If the application wishes to perform a convergence test, then
     * implement this method to set the flag to nonconverged, 0 for 
     * not converged.
     * The flag is an inout variable to avoid the need for implementing the
     * method if its utilization is not required (ie, 0 is passed in, so if
     * nothing is implemented, then 0 is passed back out).
     */
    void
    checkConvergence (
      /* inout */ int32_t& flag
    )
    throw () 
    ;


    /**
     * Starts up a component presence in the calling framework.
     * @param Svc the component instance's handle on the framework world.
     * Contracts concerning Svc and setServices:
     * 
     * The component interaction with the CCA framework
     * and Ports begins on the call to setServices by the framework.
     * 
     * This function is called exactly once for each instance created
     * by the framework.
     * 
     * The argument Svc will never be nil/null.
     * 
     * Those uses ports which are automatically connected by the framework
     * (so-called service-ports) may be obtained via getPort during
     * setServices.
     */
    void
    setServices (
      /* in */ ::gov::cca::Services services
    )
    throw ( 
      ::gov::cca::CCAException
    );

  };  // end class Component_impl

} // end namespace Minsurf

// DO-NOT-DELETE splicer.begin(Minsurf.Component._misc)
// Put miscellaneous things here...
// DO-NOT-DELETE splicer.end(Minsurf.Component._misc)

#endif
