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


C++ Order类代码示例

本文整理汇总了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();
}
开发者ID:blackberry,项目名称:OpenTTD,代码行数:60,代码来源:timetable_cmd.cpp

示例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++;
		}
	}
}
开发者ID:hippo1986,项目名称:hft-sim,代码行数:46,代码来源:OrderBook.cpp

示例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;
}
开发者ID:alexgg-developer,项目名称:3d_vj2014,代码行数:17,代码来源:Path.cpp

示例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; 
}
开发者ID:librayi,项目名称:Orderbook-Management-Program,代码行数:21,代码来源:Orderbook.cpp

示例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;
}
开发者ID:chenx859,项目名称:OrderBook-Simulation,代码行数:26,代码来源:OrderBook.cpp

示例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;
}
开发者ID:junajan,项目名称:nodejs-stock,代码行数:29,代码来源:PgsqlDataProvider.cpp

示例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);
    }
}
开发者ID:vladimiroff,项目名称:regularity,代码行数:18,代码来源:mainwindow.cpp

示例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));
  }
}
开发者ID:AfrazHussain,项目名称:tpserver-cpp,代码行数:18,代码来源:fleet.cpp

示例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;
    }
  }
}
开发者ID:junajan,项目名称:nodejs-stock,代码行数:41,代码来源:OrderMatcher.cpp

示例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;
}
开发者ID:aktiger,项目名称:bigdata,代码行数:21,代码来源:test_Order.cpp

示例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 ) );
  }
}
开发者ID:rburkholder,项目名称:trade-frame,代码行数:12,代码来源:Position.cpp

示例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;
}
开发者ID:capitalk,项目名称:collectors,代码行数:21,代码来源:HotspotFxMarketSnapshotMessage.cpp

示例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();
}
开发者ID:milczarekIT,项目名称:agila,代码行数:14,代码来源:DocumentZALController.cpp

示例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";
	}
}
开发者ID:ifzz,项目名称:AutoTrader,代码行数:22,代码来源:tradespi.cpp

示例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;
 }
开发者ID:ciech,项目名称:investo_bank,代码行数:13,代码来源:broker_with_volume_based_commission.cpp


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