//================================================================================================== // P r o g r a m Interface // B p p _ l i b r a r y // C o n s o l e // 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 provides facilities to execute the program in console mode. */
// File Name //------------------------------------------------------------------------------------- #line __LINE__ "program/bpp_library/console.hpp"
// Guardian //-------------------------------------------------------------------------------------- #ifndef guProgramBppLibraryConsole #define guProgramBppLibraryConsole
// Headers //--------------------------------------------------------------------------------------- #include <bpp/calendar.hpp> /*INCLUDE*/ #include <bpp/graph_problem.hpp> /*INCLUDE*/ #include <bpp/java.hpp> /*INCLUDE*/ #include <bpp/simulation.hpp> /*INCLUDE*/ #include <bpp/statistics.hpp> /*INCLUDE*/ #include <bpp/text_format.hpp> /*INCLUDE*/
namespace bpp {
// Importation/Exportation //----------------------------------------------------------------------- #ifdef PROGRAM_BPP_LIBRARY_DLL #define dll_export DLL_EXPORT #else #define dll_export DLL_IMPORT #endif
// Namespaces //------------------------------------------------------------------------------------ #define public_area programBppLibraryConsole #define private_area programBppLibraryConsole_private
namespace public_area { /*NAMESPACE*/ using namespace standard; } namespace private_area { using namespace public_area; }
extern_module_name;
// Initialization //-------------------------------------------------------------------------------- #define iniProgramBppLibraryConsole has_initializer;
// Macrocommands //---------------------------------------------------------------------------------
// Types & Classes //------------------------------------------------------------------------------- namespace public_area {} namespace private_area {}
// Functions Interface //--------------------------------------------------------------------------- namespace public_area { function tyReturn run(tyCardinal,tcString []); } namespace private_area {}
// Errors //---------------------------------------------------------------------------------------- namespace public_area { /*ERROR*/ extern_error erSyntax; /* Syntax error in the command line. */ }
// 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 |
//================================================================================================== // P r o g r a m Implementation // B p p _ l i b r a r y // C o n s o l e // 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__ "program/bpp_library/console.cpp"
// DLL Belonging //--------------------------------------------------------------------------------- #define PROGRAM_BPP_LIBRARY_DLL
// Headers //--------------------------------------------------------------------------------------- #include <bpp/program/bpp_library/console.hpp> /*INTERFACE*/
namespace bpp {
// Namespaces //------------------------------------------------------------------------------------ #define public_area programBppLibraryConsole #define private_area programBppLibraryConsole_private #define dll_export DLL_EXPORT
namespace public_area {} namespace private_area {}
static_module_name("Program/Bpp_library/Console");
// Initialization //-------------------------------------------------------------------------------- #undef iniProgramBppLibraryConsole static_constant(private_area::clInitializer,goInitializer);
// Errors //---------------------------------------------------------------------------------------- namespace public_area { static_error erSyntax; }
// Constants & Variables //------------------------------------------------------------------------- namespace public_area {} namespace private_area {}
// Static Members //-------------------------------------------------------------------------------- namespace public_area {} namespace private_area {}
// Functions Implementation //---------------------------------------------------------------------- namespace javaArray_private { testing_mode ( function void test(void); function void testFrame(void); ) }
namespace standardThread_private { testing_mode ( function void testBis(void); ) }
namespace public_area { //----------------------------------------------------------------------------------------------Run /*FUNCTION*/ /* Start function of the program. It deals with the commands the user gives through a command line and executes the appropriate functions. */ function tyReturn run(tyCardinal agCounter,tcString agParameterS[]) { method_name("run");
clString lcCommand; tyBoolean lcError;
tyCardinal lcCounter = 1;
environment_private::goProgramName = "B + + L i b r a r y";
try { if (agCounter==1) send_error(erSyntax);
while (lcCounter<agCounter) { lcCommand=agParameterS[lcCounter]; lcError=true;
//---------------------------------------------------------------------------------------Context if (lcCommand=="+context") { lcError=false; environment::nextLine(); environment::outContext(); }
//------------------------------------------------------------------------------------------Help else if (lcCommand=="+help") { lcError=false; environment::nextLine(); environment::inform("-=-=- H E L P -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"); environment::out(" This program tests the modules of the B++ Library.",true,true); environment::nextLine(); environment::out(" * Syntax: [commands]",true,true); environment::nextLine(); environment::out(" * Commands:",true,true); environment::out(" +context = shows the context of the program's running.",true,true); environment::out(" +help = shows this help.",true,true); environment::out(" +info = shows information about the program.",true,true); environment::out(" +license = shows the license of the program.",true,true); ampl_yes ( environment::out(" +ampl = launches the AMPL program.",true,true); ) cplex_yes ( environment::out(" +cplex = launches the CPLEX program.",true,true); ) testing_mode ( jni_yes ( environment::out(" +java = performs the testing of Jirk++.",true,true); ) environment::out(" +test = performs the testing of the modules.",true,true); safe_yes ( environment::out(" +thread = performs the testing of the thread safety.",true,true); ) ) environment::out("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-",true,true); }
//------------------------------------------------------------------------------------------Info else if (lcCommand=="+info") { lcError=false; environment::nextLine(); environment::outInformation(); }
//---------------------------------------------------------------------------------------License else if (lcCommand=="+license") { lcError=false; environment::nextLine(); environment::outLicense(); }
//------------------------------------------------------------------------------------------Ampl ampl_yes ( else if (lcCommand=="+ampl") { lcError=false; environment::nextLine(); exchangeAmpl::outInformation(); if (exchangeAmpl::valid()) { environment::nextLine(); environment::inform("AMPL Program Launching..."); exchangeAmpl::execute(""); } } )
//-----------------------------------------------------------------------------------------Cplex cplex_yes ( else if (lcCommand=="+cplex") { lcError=false; environment::nextLine(); exchangeCplex::outInformation(); if (exchangeCplex::valid()) { environment::nextLine(); environment::inform("CPLEX Program Launching..."); exchangeCplex::execute(""); } } )
//------------------------------------------------------------------------------------------Java else if (lcCommand=="+java") { testing_mode ( jni_yes ( lcError=false; environment::nextLine(); java::loadVirtualMachine(); javaArray_private::test(); javaArray_private::testFrame(); java::unloadVirtualMachine(); ) ) }
//------------------------------------------------------------------------------------------Test else if (lcCommand=="+test") { testing_mode ( lcError=false; environment::nextLine(); standardType_private::test(); standardClass_private::test(); standardAscii_private::test(); standardError_private::test(); standardConversion_private::test(); standardStream_private::test(); standardMemory_private::test(); standardMaths_private::test(); standardRandomNumber_private::test(); standardString_private::test(); standardSerialization_private::test(); standardSerialization_private::autoTest(); calendarGregorian_private::test(); calendarGregorian_private::autoTest(); dataStructureBinaryTree_private::test(); textFormatHtml_private::test(); statisticsCollector_private::test(); graphStructure_private::test(); graphAlgorithm_private::test(); linearSystemStructure_private::test(); linearSystemSolver_private::test(); graphProblemConnectivity_private::test(); graphProblemMinSpanningTree_private::test(); graphProblemShortestPath_private::test(); graphProblemMaxFlow_private::test(); graphProblemMinCostFlowStructure_private::test(); graphProblemMinCostFlowAlgorithm_private::test(); graphProblemMinCostFlowCycleCanceling_private::test(); graphProblemMinCostFlowCostScaling_private::test(); graphProblemSerialParallel_private::test(); graphProblemTensionStructure_private::test(); graphProblemMinCostTensionStructure_private::test(); graphProblemMinCostTensionAlgorithm_private::test(); graphProblemMinCostTensionAggregation_private::test(); graphProblemMinCostTensionDualCostScaling_private::test(); graphProblemTensionAlgorithm_private::test(); graphProblemMinCostTensionConforming_private::test(); graphProblemMinCostFlowLinearSystem_private::test(); graphProblemMinCostTensionLinearSystem_private::test(); graphProblemMinCostTensionAggregationBinary_private::test(); graphProblemMinCostTensionHeuristicBinary_private::test(); graphProblemMinCostTensionBranchBound_private::test(); ) }
//----------------------------------------------------------------------------------------Thread else if (lcCommand=="+thread") { testing_mode ( safe_yes ( lcError=false; environment::nextLine(); standardThread_private::test(); standardThread_private::testBis(); ) ) }
if (lcError) send_error(erSyntax); lcCounter++; } }
program_catch; } }
namespace private_area {}
// X X X Implementation //------------------------------------------------------------------------- namespace {}
// I n i t i a l i z e r Implementation //--------------------------------------------------------- namespace private_area { //--------------------------------------------------------------------------------------------Start property void clInitializer::start(void) { if (atCounter++ == 0) { try { #include <bpp/modules.hpp> /*NEED*/ registerStop(this); environment::informInitialization(goModuleName);
erSyntax.create("B++ Library - Use the '+help' parameter to get some help."); }
initializer_catch; } } //---------------------------------------------------------------------------------------------Stop property void clInitializer::stop(void) { environment::informTermination(goModuleName); } }
// End //------------------------------------------------------------------------------------------- } |
|