//==================================================================================================
// S i m u l a t i o n                                                                    Interface
// C o m m o n
//                                                                                By Bruno Bachelet
//==================================================================================================
// Copyright (c) 1999-2016
// Bruno Bachelet - bruno@nawouak.net - http://www.nawouak.net
//
// This file is part of the B++ Library. This library is free software; you can redistribute it
// and/or modify it under the terms of the GNU Library General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your option) any later
// version.
//
// This library 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 Library General Public License for more details (http://www.gnu.org).

/*DESCRIPTION*/
/* This module contains the elements shared by the submodules of <CODE>simulation</CODE>. */

// File Name //-------------------------------------------------------------------------------------
#line __LINE__ "simulation/common.hpp"

// Guardian //--------------------------------------------------------------------------------------
#ifndef guSimulationCommon
#define guSimulationCommon

// Headers //---------------------------------------------------------------------------------------
#include <bpp/standard.hpp> /*INCLUDE*/

namespace bpp {

// Importation/Exportation //-----------------------------------------------------------------------
#ifdef SIMULATION_DLL
 #define dll_export DLL_EXPORT
#else
 #define dll_export DLL_IMPORT
#endif

// Namespaces //------------------------------------------------------------------------------------
#define public_area  simulationCommon
#define private_area simulationCommon_private

namespace public_area  { /*NAMESPACE*/ using namespace standard; }
namespace private_area { using namespace public_area; }

extern_module_name;

// Initialization //--------------------------------------------------------------------------------

// Macrocommands //---------------------------------------------------------------------------------
/*MACROCOMMAND*/
/* Provides the identification of a method, i.e. its pointer and its unique number (the reference
   <CODE>simulation::clObject</CODE> is used for simulation). */
#define method_id(prClass,prMethod)                                                               \
 (void (prClass::*)())(&prClass::prMethod),method_no(simulationObject::clObject,prClass,prMethod) \

/*MACROCOMMAND*/
/* Code pattern that generates an argument name for a method (the prefix of the name is
   <CODE>ag</CODE>). Only active in the current module. */
#define vpattern_argument1(prName) ag##prName

/*MACROCOMMAND*/
/* Code pattern that generates an argument name for a method (the prefix of the name is
   <CODE>at</CODE>). Only active in the current module. */
#define vpattern_argument2(prName) at##prName

/*MACROCOMMAND*/
/* Code pattern that generates an attribute declaration for a class.
   Only active in the current module. */
#define vpattern_attribute(prName) private_property pr##prName at##prName

/*MACROCOMMAND*/
/* Code pattern that generates a construction call for an attribute of a class.
   Only active in the current module. */
#define vpattern_construction(prName) at##prName(ag##prName)

/*MACROCOMMAND*/
/* Code pattern that generates a parameter name for a template use.
   Only active in the current module. */
#define vpattern_instantiate(prName) pr##prName

/*MACROCOMMAND*/
/* Code pattern that generates a parameter name for a template definition.
   Only active in the current module. */
#define vpattern_parameterize(prName) class pr##prName

/*MACROCOMMAND*/
/* Code pattern that generates an argument signature for a method.
   Only active in the current module. */
#define vpattern_signature(prName) pr##prName ag##prName

/*MACROCOMMAND*/
/* Code pattern that generates a list of argument names for a method (the prefix of the names is
   <CODE>ag</CODE>). Only active in the current module. */
#define gpattern_argument1(prNumber) cpattern_##prNumber(argument1)

/*MACROCOMMAND*/
/* Code pattern that generates a list of argument names for a method (the prefix of the names is
   <CODE>at</CODE>). Only active in the current module. */
#define gpattern_argument2(prNumber) cpattern_##prNumber(argument2)

/*MACROCOMMAND*/
/* Code pattern that generates a list of attribute declarations for a class.
   Only active in the current module. */
#define gpattern_attribute(prNumber) spattern_##prNumber(attribute)

/*MACROCOMMAND*/
/* Code pattern that generates a list of construction calls for attributes of a class.
   Only active in the current module. */
#define gpattern_construction(prNumber) cpattern_##prNumber(construction)

/*MACROCOMMAND*/
/* Code pattern that generates a list of parameter names for a template use.
   Only active in the current module. */
#define gpattern_instantiate(prNumber) prClass,cpattern_##prNumber(instantiate)

/*MACROCOMMAND*/
/* Code pattern that generates a list of parameter names for a template definition.
   Only active in the current module. */
#define gpattern_parameterize(prNumber) class prClass,cpattern_##prNumber(parameterize)

/*MACROCOMMAND*/
/* Code pattern that generates a list of argument signatures for a method.
   Only active in the current module. */
#define gpattern_signature(prNumber) cpattern_##prNumber(signature)

/*MACROCOMMAND*/
/* Code pattern that generates the name of a method call event class (according to
   the number of arguments of the method). Only active in the current module. */
#define gpattern_class(prNumber) clMethodEvent_##prNumber

/*MACROCOMMAND*/ /* Default error handling for simulators. */
#define simulator_catch                                             \
 catch (ctError & agError) {                                        \
  outError(agError);                                                \
  if (environment::informationDisplayed()) environment::nextLine(); \
  clearError();                                                     \
 }                                                                  \
                                                                    \
 catch (tcString agMessage) {                                       \
  outError(agMessage);                                              \
  if (environment::informationDisplayed()) environment::nextLine(); \
  clearError();                                                     \
 }                                                                  \
                                                                    \
 catch (ctException & agException) {                                \
  outException(agException);                                        \
  if (environment::informationDisplayed()) environment::nextLine(); \
  clearError();                                                     \
 }                                                                  \
                                                                    \
 catch (...) {                                                      \
  outUnexpectedError();                                             \
  if (environment::informationDisplayed()) environment::nextLine(); \
  clearError();                                                     \
 }                                                                  \
                                                                    \
 if (environment::informationDisplayed()) environment::nextLine();  \

// Types & Classes //-------------------------------------------------------------------------------
namespace public_area  {}
namespace private_area {}

// Functions Interface //---------------------------------------------------------------------------
namespace public_area  {}
namespace private_area {}

// Errors //----------------------------------------------------------------------------------------
namespace public_area {}

// Constants & Variables //-------------------------------------------------------------------------
namespace public_area  {}
namespace private_area {}

// X X X  Interface //------------------------------------------------------------------------------
namespace {}

// Functions Inline //------------------------------------------------------------------------------
namespace public_area  {}
namespace private_area {}

// X X X  Inline //---------------------------------------------------------------------------------
namespace {}

// End //-------------------------------------------------------------------------------------------
}
#undef dll_export
#undef public_area
#undef private_area
#endif
 
//==================================================================================================
// S i m u l a t i o n                                                               Implementation
// C o m m o n
//                                                                                By Bruno Bachelet
//==================================================================================================
// Copyright (c) 1999-2016
// Bruno Bachelet - bruno@nawouak.net - http://www.nawouak.net
//
// This file is part of the B++ Library. This library is free software; you can redistribute it
// and/or modify it under the terms of the GNU Library General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your option) any later
// version.
//
// This library 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 Library General Public License for more details (http://www.gnu.org).

// File Name //-------------------------------------------------------------------------------------
#line __LINE__ "simulation/common.cpp"

// DLL Belonging //---------------------------------------------------------------------------------
#define SIMULATION_DLL

// Headers //---------------------------------------------------------------------------------------
#include <bpp/simulation/common.hpp> /*INTERFACE*/

namespace bpp {

// Namespaces //------------------------------------------------------------------------------------
#define public_area  simulationCommon
#define private_area simulationCommon_private
#define dll_export   DLL_EXPORT

namespace public_area  {}
namespace private_area {}

static_module_name("Simulation/Common");

// Initialization //--------------------------------------------------------------------------------

// Errors //----------------------------------------------------------------------------------------
namespace public_area {}

// Constants & Variables //-------------------------------------------------------------------------
namespace public_area  {}
namespace private_area {}

// Static Members //--------------------------------------------------------------------------------
namespace public_area  {}
namespace private_area {}

// Functions Implementation //----------------------------------------------------------------------
namespace public_area  {}
namespace private_area {}

// X X X  Implementation //-------------------------------------------------------------------------
namespace {}

// End //-------------------------------------------------------------------------------------------
}