本文整理汇总了C++中Flag::lower方法的典型用法代码示例。如果您正苦于以下问题:C++ Flag::lower方法的具体用法?C++ Flag::lower怎么用?C++ Flag::lower使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Flag
的用法示例。
在下文中一共展示了Flag::lower方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testDiscardingNotifications
void LazyObjectTest::testDiscardingNotifications() {
BOOST_TEST_MESSAGE(
"Testing that lazy object discards notifications after the first...");
boost::shared_ptr<SimpleQuote> q(new SimpleQuote(0.0));
boost::shared_ptr<Instrument> s(new Stock(Handle<Quote>(q)));
Flag f;
f.registerWith(s);
s->NPV();
q->setValue(1.0);
if (!f.isUp())
BOOST_FAIL("Observer was not notified of change");
f.lower();
q->setValue(2.0);
if (f.isUp())
BOOST_FAIL("Observer was notified of second change");
f.lower();
s->NPV();
q->setValue(3.0);
if (!f.isUp())
BOOST_FAIL("Observer was not notified of change after recalculation");
}
示例2: testObservable
void InstrumentTest::testObservable() {
BOOST_TEST_MESSAGE("Testing observability of instruments...");
boost::shared_ptr<SimpleQuote> me1(new SimpleQuote(0.0));
RelinkableHandle<Quote> h(me1);
boost::shared_ptr<Instrument> s(new Stock(h));
Flag f;
f.registerWith(s);
s->NPV();
me1->setValue(3.14);
if (!f.isUp())
BOOST_FAIL("Observer was not notified of instrument change");
s->NPV();
f.lower();
boost::shared_ptr<SimpleQuote> me2(new SimpleQuote(0.0));
h.linkTo(me2);
if (!f.isUp())
BOOST_FAIL("Observer was not notified of instrument change");
f.lower();
s->freeze();
s->NPV();
me2->setValue(2.71);
if (f.isUp())
BOOST_FAIL("Observer was notified of frozen instrument change");
s->NPV();
s->unfreeze();
if (!f.isUp())
BOOST_FAIL("Observer was not notified of instrument change");
}
示例3: testObservableHandle
void QuoteTest::testObservableHandle() {
BOOST_MESSAGE("Testing observability of quote handles...");
boost::shared_ptr<SimpleQuote> me1(new SimpleQuote(0.0));
RelinkableHandle<Quote> h(me1);
Flag f;
f.registerWith(h);
me1->setValue(3.14);
if (!f.isUp())
BOOST_FAIL("Observer was not notified of quote change");
f.lower();
boost::shared_ptr<SimpleQuote> me2(new SimpleQuote(0.0));
h.linkTo(me2);
if (!f.isUp())
BOOST_FAIL("Observer was not notified of quote change");
}
示例4: testZSpreadedObs
void TermStructureTest::testZSpreadedObs() {
BOOST_TEST_MESSAGE("Testing observability of zero-spreaded term structure...");
CommonVars vars;
ext::shared_ptr<SimpleQuote> me(new SimpleQuote(0.01));
Handle<Quote> mh(me);
RelinkableHandle<YieldTermStructure> h(vars.dummyTermStructure);
ext::shared_ptr<YieldTermStructure> spreaded(
new ZeroSpreadedTermStructure(h,mh));
Flag flag;
flag.registerWith(spreaded);
h.linkTo(vars.termStructure);
if (!flag.isUp())
BOOST_ERROR("Observer was not notified of term structure change");
flag.lower();
me->setValue(0.005);
if (!flag.isUp())
BOOST_ERROR("Observer was not notified of spread change");
}
示例5: testForwardingNotifications
void LazyObjectTest::testForwardingNotifications() {
BOOST_TEST_MESSAGE(
"Testing that lazy object forwards all notifications when told...");
boost::shared_ptr<SimpleQuote> q(new SimpleQuote(0.0));
boost::shared_ptr<Instrument> s(new Stock(Handle<Quote>(q)));
s->alwaysForwardNotifications();
Flag f;
f.registerWith(s);
s->NPV();
q->setValue(1.0);
if (!f.isUp())
BOOST_FAIL("Observer was not notified of change");
f.lower();
q->setValue(2.0);
if (!f.isUp())
BOOST_FAIL("Observer was not notified of second change");
}
示例6: printf
void *ImageProcessThread(void *threadargs)
{
long tid = (long)((struct Thread_data *)threadargs)->thread_id;
printf("ImageProcess thread #%ld!\n", tid);
CoordList localLimbs, localPixelFiducials, localScreenFiducials;
IndexList localIds;
uint8_t localMin, localMax;
std::vector<float> localMapping;
cv::Point2f localPixelCenter, localScreenCenter, localError;
timespec waittime;
waittime.tv_sec = frameRate.tv_sec/10;
waittime.tv_nsec = frameRate.tv_nsec/10;
while(1)
{
if (stop_message[tid] == 1)
{
printf("ImageProcess thread #%ld exiting\n", tid);
started[tid] = false;
pthread_exit( NULL );
}
if (cameraReady)
{
while(1)
{
if(procReady.check())
{
procReady.lower();
break;
}
else
{
nanosleep(&waittime, NULL);
}
}
//printf("ImageProcessThread: trying to lock\n");
if (pthread_mutex_trylock(&mutexImage) == 0)
{
//printf("ImageProcessThread: got lock\n");
if(!frame.empty())
{
aspect.LoadFrame(frame);
pthread_mutex_unlock(&mutexImage);
runResult = aspect.Run();
switch(GeneralizeError(runResult))
{
case NO_ERROR:
aspect.GetScreenFiducials(localScreenFiducials);
aspect.GetScreenCenter(localScreenCenter);
aspect.GetMapping(localMapping);
case MAPPING_ERROR:
aspect.GetFiducialIDs(localIds);
case ID_ERROR:
aspect.GetPixelFiducials(localPixelFiducials);
case FIDUCIAL_ERROR:
aspect.GetPixelCenter(localPixelCenter);
aspect.GetPixelError(localError);
case CENTER_ERROR:
aspect.GetPixelCrossings(localLimbs);
if (REPORT_FOCUS) aspect.ReportFocus();
case LIMB_ERROR:
case RANGE_ERROR:
aspect.GetPixelMinMax(localMin, localMax);
break;
default:
std::cout << "Nothing worked\n";
}
pthread_mutex_lock(&mutexProcess);
switch(GeneralizeError(runResult))
{
case NO_ERROR:
screenFiducials = localScreenFiducials;
screenCenter = localScreenCenter;
mapping = localMapping;
case MAPPING_ERROR:
ids = localIds;
case ID_ERROR:
pixelFiducials = localPixelFiducials;
case FIDUCIAL_ERROR:
pixelCenter = localPixelCenter;
error = localError;
case CENTER_ERROR:
limbs = localLimbs;
//.........这里部分代码省略.........
示例7: testForwardValueQuoteAndImpliedStdevQuote
void QuoteTest::testForwardValueQuoteAndImpliedStdevQuote() {
BOOST_MESSAGE(
"Testing forward-value and implied-standard-deviation quotes...");
Real forwardRate = .05;
DayCounter dc = ActualActual();
Calendar calendar = TARGET();
boost::shared_ptr<SimpleQuote> forwardQuote(new SimpleQuote(forwardRate));
Handle<Quote> forwardHandle(forwardQuote);
Date evaluationDate = Settings::instance().evaluationDate();
boost::shared_ptr<YieldTermStructure>yc (new FlatForward(
evaluationDate, forwardHandle, dc));
Handle<YieldTermStructure> ycHandle(yc);
Period euriborTenor(1,Years);
boost::shared_ptr<Index> euribor(new Euribor(euriborTenor, ycHandle));
Date fixingDate = calendar.advance(evaluationDate, euriborTenor);
boost::shared_ptr<ForwardValueQuote> forwardValueQuote( new
ForwardValueQuote(euribor, fixingDate));
Rate forwardValue = forwardValueQuote->value();
Rate expectedForwardValue = euribor->fixing(fixingDate, true);
// we test if the forward value given by the quote is consistent
// with the one directly given by the index
if (std::fabs(forwardValue-expectedForwardValue) > 1.0e-15)
BOOST_FAIL("Foward Value Quote quote yields " << forwardValue << "\n"
<< "expected result is " << expectedForwardValue);
// then we test the observer/observable chain
Flag f;
f.registerWith(forwardValueQuote);
forwardQuote->setValue(0.04);
if (!f.isUp())
BOOST_FAIL("Observer was not notified of quote change");
// and we retest if the values are still matching
forwardValue = forwardValueQuote->value();
expectedForwardValue = euribor->fixing(fixingDate, true);
if (std::fabs(forwardValue-expectedForwardValue) > 1.0e-15)
BOOST_FAIL("Foward Value Quote quote yields " << forwardValue << "\n"
<< "expected result is " << expectedForwardValue);
// we test the ImpliedStdevQuote class
f.unregisterWith(forwardValueQuote);
f.lower();
Real price = 0.02;
Rate strike = 0.04;
Volatility guess = .15;
Real accuracy = 1.0e-6;
Option::Type optionType = Option::Call;
boost::shared_ptr<SimpleQuote> priceQuote(new SimpleQuote(price));
Handle<Quote> priceHandle(priceQuote);
boost::shared_ptr<ImpliedStdDevQuote> impliedStdevQuote(new
ImpliedStdDevQuote(optionType, forwardHandle, priceHandle,
strike, guess, accuracy));
Real impliedStdev = impliedStdevQuote->value();
Real expectedImpliedStdev =
blackFormulaImpliedStdDev(optionType, strike,
forwardQuote->value(), price,
1.0, 0.0, guess, 1.0e-6);
if (std::fabs(impliedStdev-expectedImpliedStdev) > 1.0e-15)
BOOST_FAIL("\nimpliedStdevQuote yields :" << impliedStdev <<
"\nexpected result is :" << expectedImpliedStdev);
// then we test the observer/observable chain
boost::shared_ptr<Quote> quote = impliedStdevQuote;
f.registerWith(quote);
forwardQuote->setValue(0.05);
if (!f.isUp())
BOOST_FAIL("Observer was not notified of quote change");
quote->value();
f.lower();
quote->value();
priceQuote->setValue(0.11);
if (!f.isUp())
BOOST_FAIL("Observer was not notified of quote change");
}