当前位置: 首页>>代码示例>>C++>>正文


C++ SmartPtr::OSPrint方法代码示例

本文整理汇总了C++中SmartPtr::OSPrint方法的典型用法代码示例。如果您正苦于以下问题:C++ SmartPtr::OSPrint方法的具体用法?C++ SmartPtr::OSPrint怎么用?C++ SmartPtr::OSPrint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SmartPtr的用法示例。


在下文中一共展示了SmartPtr::OSPrint方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: doPrintRow

void doPrintRow(OSInstance *osinstance, std::string rownumberstring)
{
    ostringstream outStr;
    int rownumber;
    if (rownumberstring == "")
        osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_always, 
            "no row number given; print command ignored");
    else
    {
        try
        {
            rownumber = atoi((rownumberstring).c_str());
        }
        catch  (const ErrorClass& eclass)
        {
            osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_always, 
                "invalid row number; print command ignored");
        }

        if (osinstance == NULL)
        {
            osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_always, 
                "no instance defined; print command ignored");
        }
        else
        {
            outStr << std::endl << "Row " << rownumber << ":" << std::endl << std::endl;
            outStr << osinstance->printModel(rownumber) << std::endl;
            osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_always, outStr.str());
        }
    }
}// doPrintRow(OSInstance *osinstance, std::string rownumberstring) 
开发者ID:coin-or,项目名称:OS,代码行数:32,代码来源:OSAmplClient2.cpp

示例2: reportResults

/** Deal with the OSrL output generated by the call to one of the service methods
 */
void reportResults(OSCommandLine *oscommandline, std::string osrl, OSnl2OS* nl2OS)
{
    ostringstream outStr;

    if (oscommandline->osrlFile == "")
        oscommandline->osrlFile = oscommandline->nlFile + ".osrl";
    
    FileUtil* fileUtil = new FileUtil();
    fileUtil->writeFileFromString(oscommandline->osrlFile, osrl);
    
    if (oscommandline->browser != "")
    {
        std::string str = oscommandline->browser + "  "
                          + oscommandline->osrlFile;
        const char *ch = &str[0];
        std::system(ch);
    }

    // now put solution back to ampl

    OSosrl2ampl *solWriter = new OSosrl2ampl();

    try
    {
std::cout << osrl << std::endl << std::endl;
//        fileUtil->writeFileFromString(oscommandline->osrlFile, osrl);
        std::string::size_type pos1 = osrl.find( "error");
        if(pos1 == std::string::npos)
        {
            OSrLReader *osrlreader = new OSrLReader();
            OSResult *osresult = osrlreader->readOSrL( osrl);
            solWriter->writeSolFile(osrl, nl2OS->getASL("asl"), oscommandline->nlFile + ".sol");

            delete osrlreader;
            osrlreader = NULL;
        }
        else // there was an error
        {
            osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_error, osrl);
            solWriter->writeSolFile(osrl, nl2OS->getASL("asl"), oscommandline->nlFile + ".sol");
        }
        if (fileUtil != NULL)
            delete fileUtil;
        fileUtil = NULL;
    }
    catch(const ErrorClass& eclass)
    {
        outStr.str("");
        outStr.clear();
        outStr << "There was an error parsing the OSrL string" << endl << eclass.errormsg << endl << endl;
        osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_debug, outStr.str());
        if (fileUtil != NULL)
            delete fileUtil;
        fileUtil = NULL;
    }

}// reportResults
开发者ID:coin-or,项目名称:OS,代码行数:59,代码来源:OSAmplClient2.cpp

示例3: makeStrings

void makeStrings(OSCommandLine *oscommandline)
{
    // convert the osinstance and osoption objects to strings
    if (oscommandline->osil == "")
    {
        OSiLWriter *osilwriter = new OSiLWriter();
        oscommandline->osil = osilwriter->writeOSiL(oscommandline->osinstance);
#ifndef NDEBUG
        osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_trace, oscommandline->osil);
#endif
        delete osilwriter;
        osilwriter = NULL; 
    }

/** With the options we need to be a little more careful:
 *  Options can be in osol and jobID strings (either can be missing)
 *  or in an osoption object (which would include both of the above)
 *  or missing entirely (in which case a dummy string needs to be created)
 */
    OSoLReader *osolreader = NULL;
    if (oscommandline->osoption != NULL || oscommandline->jobID != "" || oscommandline->osol == "")
    {
        if (oscommandline->osoption == NULL)
        {
            oscommandline->osoption = new OSOption();
            if (oscommandline->osol != "")
            { 
                osolreader = new OSoLReader();
                oscommandline->osoption = osolreader->readOSoL(oscommandline->osol);
            }
            if (oscommandline->jobID != "")
                oscommandline->osoption->setJobID(oscommandline->jobID);
        }

        OSoLWriter *osolwriter = new OSoLWriter();
        oscommandline->osol = osolwriter->writeOSoL(oscommandline->osoption);
#ifndef NDEBUG
        osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_trace, oscommandline->osol);
#endif
        delete osolwriter;
        osolwriter = NULL;
    }
    if (osolreader != NULL)
    {
        delete osolreader;
        oscommandline->osoption = NULL; // no longer needed, and memory may have just been freed 
    }
    osolreader = NULL;
}
开发者ID:coin-or,项目名称:OS,代码行数:49,代码来源:OSAmplClient2.cpp

示例4: kill

void kill(OSCommandLine *oscommandline, OSnl2OS* nl2OS)
{
    FileUtil *fileUtil = NULL;
    fileUtil = new FileUtil();
    std::string osplOutput = "";
    OSSolverAgent* osagent = NULL;
    try
    {
        if (oscommandline->serviceLocation != "")
        {
            osagent = new OSSolverAgent(oscommandline->serviceLocation);

            if (oscommandline->osol == "")
            {
                // we need to construct the OSoL
                OSOption *osOption = NULL;
                osOption = new OSOption();
                // get a jobId if necessary
                if (oscommandline->jobID == "") throw ErrorClass("there is no JobID");
                //set the jobID
                osOption->setJobID( oscommandline->jobID);
                // now read the osOption object into a string
                OSoLWriter *osolWriter = NULL;
                osolWriter = new OSoLWriter();
                oscommandline->osol = osolWriter->writeOSoL( osOption);
                delete osOption;
                osOption = NULL;
                delete osolWriter;
                osolWriter = NULL;
            }

            osplOutput = osagent->kill(oscommandline->osol);

            if (oscommandline->osplOutputFile != "")
                fileUtil->writeFileFromString(oscommandline->osplOutputFile, osplOutput);
            else
                osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_summary, osplOutput);
            delete osagent;
            osagent = NULL;
        }
        else
        {
            delete osagent;
            osagent = NULL;
            throw ErrorClass("please specify service location (url)");
        }
        delete fileUtil;
        fileUtil = NULL;
    }
    catch (const ErrorClass& eclass)
    {
        reportErrors(oscommandline, eclass.errormsg, nl2OS);
        if (osagent != NULL)
            delete osagent;
        osagent = NULL;

        delete fileUtil;
        fileUtil = NULL;
    }
}//end kill
开发者ID:coin-or,项目名称:OS,代码行数:60,代码来源:OSAmplClient2.cpp

示例5: getJobID

void getJobID(OSCommandLine *oscommandline, OSnl2OS* nl2OS)
{
    OSSolverAgent* osagent = NULL;
    try
    {
        if (oscommandline->serviceLocation != "")
        {
            osagent = new OSSolverAgent(oscommandline->serviceLocation);
            oscommandline->jobID = osagent->getJobID(oscommandline->osol);
            osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_error, oscommandline->jobID);
            delete osagent;
            osagent = NULL;
        }
        else
        {
            delete osagent;
            osagent = NULL;
            throw ErrorClass("please specify service location (url)");
        }
    }

    catch (const ErrorClass& eclass)
    {
        reportErrors(oscommandline, eclass.errormsg, nl2OS);
        if (osagent != NULL)
            delete osagent;
        osagent = NULL;
    }
}//end getJobID
开发者ID:coin-or,项目名称:OS,代码行数:29,代码来源:OSAmplClient2.cpp

示例6: findInstance

/** This method tries to find the instance by reading the .nl file.
 *  This is the only acceptable format, since AMPL has just written
 *  the content of the model to a temporary file. 
 *  @param oscommandline: contains the information processed so far
 *  @return whether an instance was found or not
 */
bool findInstance(OSCommandLine *oscommandline, OSnl2OS *nl2os)
{
//    FileUtil *fileUtil = NULL;
//    fileUtil = new FileUtil();

    try
    {
//        nl2os = new OSnl2OS();
        if (!nl2os->readNl(oscommandline->nlFile))
            throw ErrorClass("Error reading .nl file.");
        nl2os->setOsol(oscommandline->osol);
        nl2os->setJobID(oscommandline->jobID);
        nl2os->createOSObjects() ;
        oscommandline->osinstance = nl2os->osinstance;
        return true;
    }
    catch (const ErrorClass& eclass)
    {
        osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_error, eclass.errormsg);
        //throw ErrorClass(eclass.errormsg);
        return false;
    }
}//findInstance
开发者ID:coin-or,项目名称:OS,代码行数:29,代码来源:OSAmplClient2.cpp

示例7: send

void send(OSCommandLine *oscommandline, OSnl2OS *nl2OS)
{
    bool bSend = false;
    bool always_print = false;
    OSSolverAgent* osagent = NULL;
    ostringstream outStr;

    try
    {
        osagent = new OSSolverAgent(oscommandline->serviceLocation);


        // get a job ID if necessary
        if (oscommandline->jobID == "NEW")
        {
            always_print = true;
            oscommandline->jobID = osagent->getJobID("");
            if (oscommandline->osoption != NULL)
                oscommandline->osoption->setJobID(oscommandline->jobID);
        }

        makeStrings(oscommandline);

        outStr.str("");
        outStr.clear();
        outStr << "Submitting Job " << oscommandline->jobID << std::endl;
        osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_info, outStr.str());

        bSend = osagent->send(oscommandline->osil, oscommandline->osol);

        outStr.str("");
        outStr.clear();
        outStr << "Job " << oscommandline->jobID;

        if (bSend == true)
        {
            outStr << " successfully submitted." << std::endl;
            if (always_print)
                osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_always, outStr.str());
            else
                osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_info,   outStr.str());
        }
        else
        {
            outStr << ": send failed." << std::endl;
            outStr << "Check to make sure you sent a jobID not on the system." << std::endl;
            osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_error, outStr.str());
        }
          
        delete osagent;
        osagent = NULL;
    }

    catch (const ErrorClass& eclass)
    {
        reportErrors(oscommandline, eclass.errormsg, nl2OS);
        if (osagent != NULL)
            delete osagent;
        osagent = NULL;
    }
}//end send
开发者ID:coin-or,项目名称:OS,代码行数:61,代码来源:OSAmplClient2.cpp

示例8: main

int main(int argc, char **argv)
{
    WindowsErrorPopupBlocker();
    std::ostringstream outStr;
    OSnl2OS *nl2OS = new OSnl2OS();
    OSiLReader* osilreader = new OSiLReader(); 
    FileUtil *fileUtil = NULL;
    ostringstream echo_cl;

    // initialize the command line structure 

    OSCommandLine *oscommandline;// = new OSCommandLine();
    OSCommandLineReader *oscommandlinereader = new OSCommandLineReader();

    DefaultSolver *solverType  = NULL;
    char* stub = NULL;
    if (argc > 0) stub = argv[1];

    // getting the OSAmplClient_options into a std::string is a bit of a pain...
    char* temp = getenv("OSAmplClient_options");
    ostringstream temp2;
    std::string amplclient_options;
    if (temp != NULL)
    {
        temp2 << temp; 
        amplclient_options = temp2.str();
        std::cout << amplclient_options << std::endl;
    }
    else
//        amplclient_options = "";
        amplclient_options = "serviceMethod retrieve serviceLocation http://74.94.100.129:8080/OSServer/services/OSSolverService printLevel 4 jobID gus-10-apr-2013-0001";

    // this output must be held in abeyance  until the command line
    // has been processed and printLevel has been set...
#ifndef NDEBUG
    echo_cl << "HERE ARE THE AMPLCLIENT OPTIONS ";
    echo_cl << amplclient_options;
    echo_cl << endl << endl;

    echo_cl << "Try to open file ";
    echo_cl << stub << ".nl";
    echo_cl << endl;
#endif

    // Now read the command line
    try
    {
        oscommandline = oscommandlinereader->readCommandLine(amplclient_options);
    }

    catch (const ErrorClass& eclass)
    {
        reportErrors(oscommandline, eclass.errormsg, nl2OS);
        delete oscommandlinereader;
        oscommandlinereader = NULL;
        return 1;
    }

    if (stub) oscommandline->nlFile = stub;


    /** Deal with action items: -printLevel, -logFile, -filePrintLevel, --help, --version **/

    try
    {
        outStr.str("");
        outStr.clear();
        outStr << std::endl << "using print level " << oscommandline->printLevel << " for stdout" << std::endl;

        if (oscommandline->printLevel != DEFAULT_OUTPUT_LEVEL)
        {
            osoutput->SetPrintLevel("stdout", (ENUM_OUTPUT_LEVEL)oscommandline->printLevel);

#ifndef NDEBUG
            osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_trace, echo_cl.str());
#endif
            osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_info, outStr.str());
        }
#ifndef NDEBUG
        else
        {
            osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_trace, echo_cl.str());
            osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_debug, outStr.str());            
        }
#endif

        if (oscommandline->logFile != "")
        {
            int status = osoutput->AddChannel(oscommandline->logFile);
 
            switch(status)
            {
                case 0:
                    osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_info,
                        "Added channel " + oscommandline->logFile);
                    break;          
                case 1:
                    osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_info,
                        "Output channel " + oscommandline->logFile + " previously defined");
                    break;
//.........这里部分代码省略.........
开发者ID:coin-or,项目名称:OS,代码行数:101,代码来源:OSAmplClient2.cpp


注:本文中的SmartPtr::OSPrint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。