view src/fem_init_env.cc @ 44:fca8c3d75036

register_type is called before every type is used. * A new static variable for every class has been defined. It is named class_type_loaded, and it specify if the corresponding type have yet been loaded or not. If not, it proceed with the registration. This should be only a temporary solution.
author gedeone-octave <marco.vassallo@outlook.com>
date Mon, 22 Jul 2013 11:33:50 +0200
parents f992cee90bd6
children a64e195d0611
line wrap: on
line source

/*
 Copyright (C) 2013 Marco Vassallo

 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
 Foundation; either version 2 of the License, or (at your option) any later
 version.

 This program 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 General Public License for more
 details.

 You should have received a copy of the GNU General Public License along with
 this program; if not, see <http://www.gnu.org/licenses/>.
*/


#include "mesh.h"
#include "functionspace.h"
#include "boundarycondition.h"
#include "coefficient.h"

DEFINE_OCTAVE_ALLOCATOR (mesh);
DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (mesh, "mesh", "mesh");

DEFINE_OCTAVE_ALLOCATOR (functionspace);
DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (functionspace, "functionspace", "functionspace");

DEFINE_OCTAVE_ALLOCATOR (boundarycondition);
DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (boundarycondition, "boundarycondition", "boundarycondition");

DEFINE_OCTAVE_ALLOCATOR (coefficient);
DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (coefficient, "coefficient", "coefficient");

DEFUN_DLD (fem_init_env, args, , "-*- texinfo -*-\n\
@deftypefn {Function File} {[]} = \
fem_init_env ( ) \n\
Initialize the environment for fem-fenics\n\
@end deftypefn")
{
  int nargin = args.length ();
  octave_value retval;

  if (nargin < 0 || nargin > 0)
    print_usage ();
  else
    {
      mesh::register_type ();
      mesh_type_loaded = true;
      std::cout << "mesh_type_loaded" << std::endl;
      functionspace::register_type ();
      functionspace_type_loaded = true;
      std::cout << "functionspace_type_loaded" << std::endl;
      boundarycondition::register_type ();
      boundarycondition_type_loaded = true;
      std::cout << "boundarycondition_type_loaded" << std::endl;
      coefficient::register_type ();
      coefficient_type_loaded = true;
      std::cout << "coefficient_type_loaded" << std::endl;
      mlock ();
    }
  return retval;
}