コード例 #1
0
ファイル: savingAccountTest.cpp プロジェクト: zcgu/C-_4
void savingAccountTest()
{
    SavingAccount saver1(0.03, 2000, "zhangsan");
    SavingAccount saver2(0.03, 3000, "lisi");

    saver1.print();
    saver2.print();
    cout <<endl;

    saver1.annualInterestRate=0.04;
    cout<<"改变年利率至0.04"<<endl;
    saver1.print();
    saver2.print();

}
コード例 #2
0
ファイル: text-file-saver.cpp プロジェクト: gang-chen/samoyed
int main()
{
    g_type_init();

    Samoyed::Scheduler scheduler(2);

    char *pwd = g_get_current_dir();

    std::string fileName1(pwd);
    fileName1 += G_DIR_SEPARATOR_S "text-file-saver-test.GBK";
    char *uri1 = g_filename_to_uri(fileName1.c_str(), NULL, NULL);
    if (!uri1)
    {
        printf("File name to URI conversion error.\n");
        return -1;
    }
    boost::shared_ptr<char> textUtf8(g_strdup(TEXT_UTF8), g_free);
    boost::shared_ptr<Samoyed::TextFileSaver> saver1(
        new Samoyed::TextFileSaver(scheduler, 1, uri1, textUtf8, -1,
                                   "GBK"));
    saver1->addFinishedCallback(onDone);
    saver1->addCanceledCallback(onDone);
    g_free(uri1);

    std::string fileName2(pwd);
    fileName2 += G_DIR_SEPARATOR_S "text-file-saver-test.UTF-8";
    char *uri2 = g_filename_to_uri(fileName2.c_str(), NULL, NULL);
    if (!uri2)
    {
        printf("File name to URI conversion error.\n");
        return -1;
    }
    boost::shared_ptr<Samoyed::TextFileSaver> saver2(
        new Samoyed::TextFileSaver(scheduler, 1, uri2, textUtf8, -1,
                                   "UTF-8"));
    saver2->addFinishedCallback(onDone);
    saver2->addCanceledCallback(onDone);
    g_free(uri2);

    saver1->submit(saver1);
    saver2->submit(saver2);
    scheduler.wait();

    g_free(pwd);
    return 0;
}
コード例 #3
0
ファイル: TestMon.cpp プロジェクト: binghuo365/BaseLab
int
MyTask::svc ()
{
    Guard_Monitor guard(this->monitor_);

    int num = ++num_threads_;

    ACE_ERROR ((LM_ERROR,
        ACE_TEXT ("(%t) MyTask::begin thread %d\n"),
        num));

    guard.signal ();


    while (!flg_stop_)
    {
        ACE_ASSERT (guard.locked ());
        {
            Save_Guard saver (guard, Save_Guard::RELEASE);
            ACE_ASSERT (!guard.locked ());

            {
                Save_Guard saver2 (guard, Save_Guard::ACQUIRE);
                ACE_ASSERT (guard.locked ());
            }
            ACE_ASSERT (!guard.locked ());

            ACE_OS::sleep (1);
        }
    }

    --num_threads_;
    ACE_ERROR ((LM_ERROR,
        ACE_TEXT ("(%t) MyTask::end thread %d , remain %d\n"),
        num, num_threads_));

    guard.signal ();
    ACE_ASSERT (guard.locked ());

    return 0;
}
コード例 #4
0
ファイル: TailsAdvData.cpp プロジェクト: suppertails66/tales
void TailsAdvData::save(std::string& data) {
  
  /* A VERY LONG SEQUENCE OF SAVES GOES HERE */
  
  SaveHelper saver(data,
                   DataChunkIDs::fileStart,
                   0);
  
  standardPalettes_.save(data);
  paletteCycles_.save(data);
  levelEffectsHeaders_.save(data);
  levelPaletteHeaders_.save(data);
  levelGraphicsData_.save(data);
  tileMaps_.save(data);
  leafGraphicsTable_.save(data);
  waterSplashGraphicTable_.save(data);
  smokePuffGraphicTable_.save(data);
  spriteMappings_.save(data);
  musicAssignments_.save(data);
  radioMusic_.save(data);
  powerUpData_.save(data);
  emeraldHealthRefills_.save(data);
  metatileWidthMaps_.save(data);
  metatileHeightMaps_.save(data);
  slopeSpeedValues_.save(data);
  metatileBehaviors_.save(data);
  spawnPoints_.save(data);
  warpDestinations_.save(data);
  levelObjectEntryGroups_.save(data);
  mapData_.save(data);
  
  SaveHelper saver2(data,
                   DataChunkIDs::fileEnd,
                   0);
  
  saver2.finalize();
  
  saver.finalize();
}
コード例 #5
0
void save2(const T& t)
{
	boost::fusion::for_each(t, saver2());
}