本文整理汇总了C++中Order类的典型用法代码示例。如果您正苦于以下问题:C++ Order类的具体用法?C++ Order怎么用?C++ Order使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Order类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CmdChangeTimetable
/**
* Add or remove waiting times from an order.
* @param tile Not used.
* @param flags Operation to perform.
* @param p1 Various bitstuffed elements
* - p1 = (bit 0-19) - Vehicle with the orders to change.
* - p1 = (bit 20-27) - Order index to modify.
* - p1 = (bit 28) - Whether to change the waiting time or the travelling
* time.
* @param p2 The amount of time to wait.
* - p2 = (bit 0-15) - Waiting or travelling time as specified by p1 bit 28
* @param text unused
* @return the cost of this operation or an error
*/
CommandCost CmdChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
VehicleID veh = GB(p1, 0, 20);
Vehicle *v = Vehicle::GetIfValid(veh);
if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
if (ret.Failed()) return ret;
VehicleOrderID order_number = GB(p1, 20, 8);
Order *order = v->GetOrder(order_number);
if (order == NULL || order->IsType(OT_IMPLICIT)) return CMD_ERROR;
bool is_journey = HasBit(p1, 28);
int wait_time = order->wait_time;
int travel_time = order->travel_time;
if (is_journey) {
travel_time = GB(p2, 0, 16);
} else {
wait_time = GB(p2, 0, 16);
}
if (wait_time != order->wait_time) {
switch (order->GetType()) {
case OT_GOTO_STATION:
if (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) return_cmd_error(STR_ERROR_TIMETABLE_NOT_STOPPING_HERE);
break;
case OT_CONDITIONAL:
break;
default: return_cmd_error(STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS);
}
}
if (travel_time != order->travel_time && order->IsType(OT_CONDITIONAL)) return CMD_ERROR;
if (flags & DC_EXEC) {
if (wait_time != order->wait_time) ChangeTimetable(v, order_number, wait_time, false);
if (travel_time != order->travel_time) ChangeTimetable(v, order_number, travel_time, true);
}
return CommandCost();
}
示例2: while
void OrderBook::runOrderBook()
{
Order orderToExecute;
while(open){
if(orders.try_pop(orderToExecute)){
switch(orderToExecute.m_type)
{
case LIMIT_SELL:
//std::cout << "limit sell :" << std::endl;
processLimitSellOrder(orderToExecute);
break;
case LIMIT_BUY:
//std::cout << "limit buy : " << std::endl;
processLimitBuyOrder(orderToExecute);
break;
case MARKET_SELL:
//std::cout << "market sell" << std::endl;
processMarketSellOrder(orderToExecute);
break;
case MARKET_BUY:
//std::cout << "market buy" << std::endl;
processMarketBuyOrder(orderToExecute);
break;
case CANCEL_BUY:
//std::cout << "cancel buy" << std::endl;
processBuyCancellation(orderToExecute.m_owner, orderToExecute.m_globalOrderIdentifier, orderToExecute.getPrice(), orderToExecute.m_time);
break;
case CANCEL_SELL:
//std::cout << "cancel sell" << std::endl;
processSellCancellation(orderToExecute.m_owner, orderToExecute.m_globalOrderIdentifier, orderToExecute.getPrice(), orderToExecute.m_time);
break;
case CLEAR_OB:
/*cleanOrderBook();
setDefaultBidAsk(orderToExecute.m_newBid, orderToExecute.m_newAsk);*/
break;
default:
break;
}
m_linkToMarket->updateCurrentTime(orderToExecute.m_time);
m_linkToMarket->notifyAllAgents();
if(orderToExecute.getOwner() == 3)
nbOrderMM++;
nbOrder++;
}
}
}
示例3: assert
bool Path::Load(pugi::xml_node const& aPathNode) {
mName = aPathNode.attribute("name").value();
mStartPosition.x = static_cast<float>(aPathNode.child("start_point").attribute("x").as_float());
mStartPosition.y = static_cast<float>(aPathNode.child("start_point").attribute("y").as_int());
for(pugi::xml_node const& aOrderNode : aPathNode.children("order")) {
Order o;
if(!o.Load(aOrderNode)) {
std::cout << "Could not load order on path" << std::endl;
assert(0);
return false;
}
mOrders.push_back(o);
}
return true;
}
示例4: Message
void Orderbook::insertOrdertoAsk(Order order)
{
Message *insertMessage = new Message();
// look for order price set (key & vector) in the ask map
map<double, vector<Order>>::iterator orderInMap = Ask.find(order.getLimitPrice());
if (orderInMap == Ask.end()) // had not found
{
vector<Order> newVector;
newVector.push_back(order);
Ask.insert(pair <double, vector<Order>>(order.getLimitPrice(), newVector));
insertMessage->insertToNewMapPrice(order);
}
else // Map already has orders with same price
{
orderInMap->second.push_back(order);
insertMessage->insertToVector(order, (int)orderInMap->second.size());
}
delete insertMessage;
}
示例5: Order
void OrderBook::displayBids() //Function to display Bids
{
deque<Order*> x1;
Order* x = new Order();
if(BidBook.empty())
{
cout<<"There are no Bid Orders. The book is empty"<<endl<<endl<<endl;
return;
}
for(map<double,deque<Order*> >::iterator it=BidBook.begin(); it!=BidBook.end(); it++)
{
x1 = it->second; //Get Queue from that particular price and iterate over it
for (deque<Order*>::iterator it2 = x1.begin(); it2!=x1.end(); it2++)
{
x = *it2;
cout<<"Name: "<<x->getCounterParty()<<endl;
cout<<"Security: "<<x->getSecurity()<<endl;
cout<<"Type: "<<x->getType()<<endl;
cout<<"Quantity: "<<x->getQuantity()<<endl;
cout<<"Price: "<<x->getLimit()<<endl;
}
}
return;
}
示例6: command
OrderList PgsqlDataProvider::getOrders(OrderType type, string methodName, uint32_t stockId)
{
OrderList orderList;
nontransaction command(*conn);
string query = "SELECT id, broker_id, stock_id, amount, price FROM " + methodName + "(" + to_string(stockId) + ");";
result queryResult(command.exec(query));
if (verbose)
cout << "Result of " << query << ": " << endl;
ResultIterator endIterator = queryResult.end();
for (ResultIterator iterator = queryResult.begin(); iterator != endIterator; ++iterator)
{
Order order;
order.setId(iterator[0].as<uint64_t>());
order.setType(type);
order.setBrokerId(iterator[1].as<uint32_t>());
order.setStockId(iterator[2].as<uint32_t>());
order.setAmount(iterator[3].as<uint32_t>());
order.setPrice(Decimal(iterator[4].as<string>()));
orderList.push_back(order);
}
if (verbose)
cout << orderList.size() << " orders. " << endl;
return orderList;
}
示例7: enableInput
void MainWindow::onOrderTaken() {
ui->answer->setText("^");
enableInput();
int id = factory->take_order();
if(id == -1) {
ui->orderInfo->setText("");
disableInput();
} else {
factory->remove_order(id);
Order* order = factory->get_order_in_progress();
QStringList words;
for (std::string word : order->get_words()) {
words << QString(word.c_str());
}
ui->orderInfo->setText(words.join(", "));
ui->takeOrder->setDisabled(true);
}
}
示例8: doOnceATurn
void Fleet::doOnceATurn(){
Game* game = Game::getGame();
IGObject * pob = game->getObjectManager()->getObject(obj->getParent());
uint32_t obT_Planet = game->getObjectTypeManager()->getObjectTypeByName("Planet");
if(pob->getType() == obT_Planet && ((Planet*)(pob->getObjectBehaviour()))->getOwner() == getOwner()){
IntegerObjectParam* damage = ((IntegerObjectParam*)(obj->getParameter(4,2)));
if(damage->getValue() != 0){
damage->setValue(0);
obj->touchModTime();
}
}
game->getObjectManager()->doneWithObject(obj->getParent());
Order* order = game->getOrderManager()->getOrderQueue(((OrderQueueObjectParam*)(obj->getParameter(3,1)))->getQueueId())->getFirstOrder();
if(order == NULL || order->getType() != game->getOrderManager()->getOrderTypeByName("Move")){
setVelocity(Vector3d(0,0,0));
}
}
示例9: while
void OrderMatcher::matchOrders(TradeList& tradeList, OrderList& buyList, OrderList& sellList, Decimal price)
{
if (verbose)
cout << endl << "Matching orders..." << endl;
if (buyList.size() == 0 || sellList.size() == 0)
return;
Order buyOrder = buyList.front();
Order sellOrder = sellList.front();
bool finished = false;
while (!finished && buyOrder.getPrice() >= price && sellOrder.getPrice() <= price)
{
uint32_t amount = std::min(buyOrder.getAmount(), sellOrder.getAmount());
Trade trade(amount, price, buyOrder, sellOrder);
tradeList.push_back(trade);
buyOrder.decreaseAmount(amount);
sellOrder.decreaseAmount(amount);
if (buyOrder.getAmount() == 0)
{
buyList.pop_front();
if (buyList.size() > 0)
buyOrder = buyList.front();
else
finished = true;
}
if (sellOrder.getAmount() == 0)
{
sellList.pop_front();
if (sellList.size() > 0)
sellOrder = sellList.front();
else
finished = true;
}
}
}
示例10: main
int main()
{
GOOGLE_PROTOBUF_VERIFY_VERSION;
Order order;
initOrder(&order);
// serialize object to string
std::string order_str;
order.SerializeToString(&order_str);
std::cout << order_str << std::endl;
std::string Order_debug = order.DebugString();
std::cout << Order_debug << std::endl;
Order order_2;
order_2.ParseFromString(order_str);
google::protobuf::ShutdownProtobufLibrary();
return 0;
}
示例11: HandleCommission
void Position::HandleCommission( const Order& order ) {
//std::cout << "Position Comm: " << m_row.dblCommissionPaid << "," << order.GetCommission();
double dblNewCommissionPaid = order.GetIncrementalCommission();
//std::cout << "," << dblNewCommissionPaid << std::endl;
if ( 0 != dblNewCommissionPaid ) {
m_row.dblCommissionPaid += dblNewCommissionPaid;
OnUpdateCommissionForPortfolioManager( *this );
OnCommission( PositionDelta_delegate_t( *this, 0, dblNewCommissionPaid ) );
}
}
示例12: while
bool BidOrOffer::Load(PacketBase& packet)
{
m_lstOrders.clear();
if (!packet.ReadString(m_strBidPrice, 10))
return false;
int nOrderCount;
if (!packet.ReadInt(nOrderCount, 4))
return false;
while (--nOrderCount >= 0)
{
Order order;
if (!order.Load(packet))
return false;
m_lstOrders.push_back(order);
}
return true;
}
示例13: insertOrderData
void DocumentZALController::insertOrderData(Order order)
{
view->getLineOrderSymbol()->setText(order.getSymbol());
view->setContractorData(order.getContractor());
view->setLineIssueName(order.getIssueName());
view->setLineReceiveName(order.getReceiveName());
view->setLineDiscount(order.getDiscount());
view->setLineDocumentPlace(order.getDocumentPlace());
manager->setContractor(order.getContractor());
manager->setDocumentPositions(order.getDocumentPositions());
manager->countGoodsValue(view->getDiscountOrWaybillNo()->text().toDouble());
setGoodsValue();
addGood();
}
示例14: Order
void CtpTradeSpi::ReqOrderInsert(Order ord){
SYNC_PRINT << ("Execute Order (") << ord.GetInstrumentId() << ", " \
<< ord.GetRefExchangePrice() << ", " \
<< (ord.GetExchangeDirection() == THOST_FTDC_D_Buy ? "Buy)" : "Sell)");
ord.SetIdentityInfo(m_brokerID, m_userID, m_userID, m_orderRef);
int nextOrderRef = atoi(m_orderRef);
SPRINTF(m_orderRef, "%d", ++nextOrderRef);
CThostFtdcInputOrderField ordstruct;
bool success = ord.GetOrderOriginStruct(ordstruct);
if (success){
SYNC_PRINT << "[Debug] 插入订单:" << CommonUtils::StringFromStruct(ordstruct);
int ret = pUserApi->ReqOrderInsert(&ordstruct, ++requestId);
SYNC_PRINT << "[Trade] 请求 | 插入订单..." << ((ret == 0) ? "成功" : "失败");
//if (ret)
// g_OrderRunMtx.unlock();
}
else{
SYNC_PRINT << "[Trade] Invalid OrderField construct";
}
}
示例15: calculate_commission
double BrokerWithVolumeBasedCommission::calculate_commission(const Order & order) const
{
const int volume = order.volume();
if (volume <= 40)
{
return 0.03;
}
else if (volume <= 80)
{
return 0.025;
}
return 0.02;
}