示例#1
0
void
MooseEnumBase::addEnumerationName(const std::string & raw_name)
{
  // Make sure the option is not malformed
  if (raw_name.find_first_of('=') == 0 || raw_name.find_last_of('=') == raw_name.length() - 1)
    mooseError("You cannot place whitespace around the '=' character in MooseEnumBase");

  // Split on equals sign
  std::vector<std::string> name_value;
  MooseUtils::tokenize(MooseUtils::trim(raw_name), name_value, 1, "=");

  // There should be one or two items in the name_value
  if (name_value.size() < 1 || name_value.size() > 2)
    mooseError("Invalid option supplied in MooseEnumBase: ", raw_name);

  // Remove un-wanted space around string
  name_value[0] = MooseUtils::trim(name_value[0]);

  // See if there is a value supplied for this option
  // strtol allows for proper conversions of both int and hex strings
  int value;
  if (name_value.size() == 2)
    value = std::strtol(name_value[1].c_str(), NULL, 0);
  else
    value = getNextValidID();

  addEnumerationName(name_value[0], value);
}
示例#2
0
void PosixIBClient::placeOrder()
{
	Contract contract;
	Order order;

    contract.symbol = "ES";
    contract.secType = "FUT";
    contract.exchange = "GLOBEX";
    contract.expiry = "201509";
	contract.currency = "USD";

    order.action = "BUY";
    order.totalQuantity = 5;
	order.orderType = "LMT";
    order.lmtPrice = 2045.00;

    qDebug() << "Placing order using ID:" << nextOrderId;
    pClient->placeOrder(nextOrderId, contract, order);
    getNextValidID();
}
    void GameManager::loadGameMapWithSingle(const char* fileName)
    {
        if( _gameMap != nullptr )
        {
            throw std::runtime_error("<GameManager::loadGameMap> GameMap is already exist.");
        }

        _loadCellSpaceAndMap(fileName);
        
        std::vector<Vec2> startingPoints = getGameMap()->getStartingLocationData();
        log("<GameManager::loadGameMap> Created Human at (%.0f, %.0f)", startingPoints.front().x, startingPoints.front().y);
        EntityHuman* human = EntityHuman::create(this);
        human->setWorldPosition(startingPoints.front());
        human->setVisibleCrossHair(true);
        registEntity(human, getNextValidID(), Z_ORDER_HUMAN);
        setPlayer(human);
        
        
        for(int i = 1 ; i < startingPoints.size() ; ++ i)
        {
            log("<GameManager::loadGameMap> Created Human at (%.0f, %.0f)", startingPoints[i].x, startingPoints[i].y);
            EntityHuman* human = EntityHuman::create(this);
            human->setWorldPosition(startingPoints[i]);
            registEntity(human, getNextValidID(), Z_ORDER_HUMAN);
        }
        
        
//        std::vector<NameCoordAmount> items = getGameMap()->getItemData();
//        for(int i = 0 ; i < items.size() ; ++ i)
//        {
//            log("<GameManager::loadGameMap> Created Items at (%.0f, %.0f)", items[i].pos.x, items[i].pos.y);
//            
//            if ( items[i].name == "Glock22" )
//            {
//                ItemGlock17* glock17 = ItemGlock17::create(this, "Glock17.png", "Glock17.png", "Glock17.png",
//                                                           ui::Widget::TextureResType::PLIST);
//                glock17->setPosition(items[i].pos);
//                glock17->setAmount(items[i].amount);
//                registEntity(glock17, getNextValidID(), Z_ORDER_ITEMS);
//            }
//            else if (items[i].name == "M16A4" )
//            {
//                ItemM16A2* m16a2 = ItemM16A2::create(this, "M16A2.png", "M16A2.png", "M16A2.png",
//                                                     ui::Widget::TextureResType::PLIST);
//                m16a2->setPosition(items[i].pos);
//                m16a2->setAmount(items[i].amount);
//                registEntity(m16a2, getNextValidID(), Z_ORDER_ITEMS);
//            }
//            else if (items[i].name == "Axe" )
//            {
//                ItemAxe* axe = ItemAxe::create(this, "Axe.png", "Axe.png", "Axe.png",
//                                               ui::Widget::TextureResType::PLIST);
//                axe->setPosition(items[i].pos);
//                axe->setAmount(items[i].amount);
//                registEntity(axe, getNextValidID(), Z_ORDER_ITEMS);
//            }
//            else if (items[i].name == "M1897" )
//            {
//                ItemM1897* m1897 = ItemM1897::create(this, "M1897.png", "M1897.png", "M1897.png",
//                                                     ui::Widget::TextureResType::PLIST);
//                m1897->setPosition(items[i].pos);
//                m1897->setAmount(items[i].amount);
//                registEntity(m1897, getNextValidID(), Z_ORDER_ITEMS);
//            }
//            else if (items[i].name == "5_56mm")
//            {
//                Bullet556mm* bullet556mm = Bullet556mm::create(this, "5_56mm.png", "5_56mm.png", "5_56mm.png", ui::Widget::TextureResType::PLIST);
//                bullet556mm->setPosition(items[i].pos);
//                bullet556mm->setAmount(items[i].amount);
//                registEntity(bullet556mm, getNextValidID(), Z_ORDER_ITEMS);
//            }
//            else if (items[i].name == "9mm")
//            {
//                Bullet9mm* bullet9mm = Bullet9mm::create(this, "9mm.png", "9mm.png", "9mm.png", ui::Widget::TextureResType::PLIST);
//                bullet9mm->setPosition(items[i].pos);
//                bullet9mm->setAmount(items[i].amount);
//                registEntity(bullet9mm, getNextValidID(), Z_ORDER_ITEMS);
//            }
//        }
    }