Esempio n. 1
0
/**
 * 记录变量的论域
 * @param _variable 变量名
 * @param _domain 论域名
 */
void Vocabulary::setVariableDomain(const char* _variable, const char* _domain) {
    int domainId = getSymbolId(_domain, DOMAIN);
    int variableId;
    
    if(domainId == -1) {
        domainId = m_nDomainId ++;
        m_mapDomainName[domainId] = _domain;
    }
    if((variableId = getSymbolId(_variable, VARIABLE)) != -1) {
        m_mapVariableDomain[variableId] = domainId;
        if (! Utils::isInList(variableId, m_mapDomainVariables[domainId])) {
            m_mapDomainVariables[domainId].push_back(variableId);
        }
    }
}
Esempio n. 2
0
int MDSubscribeRequest::serialize(char* buf)
{
  int bytes = 0;
  UNSIGNED_CHARACTER tmpChar = 0;
  UNSIGNED_LONG tmpLong = 0;
  UNSIGNED_SHORT tmpShort = 0;

  bytes = sizeof(UNSIGNED_SHORT);  // Leave 2 bytes for packet size
  
  // Put category of command
  SERIALIZE_8(tmpChar, 
      (UNSIGNED_CHARACTER)(CMD::CommandCategory_MARKET_DATA_SUBSCRIPTION), 
      buf, 
      bytes);  //Command Category

  // Put fields of this class
  SERIALIZE_16(tmpShort, isSubscriptionReq(), buf, bytes);
  SERIALIZE_64(tmpLong, getSymbolId(), buf, bytes);
  //memcpy(buf + bytes, getLoginToken(), TOKEN_LENGTH);
  SERIALIZE_16(tmpShort, getUserId(), buf, bytes);
  
  UNSIGNED_SHORT dummyBytes = 0;
  // Put size as the first field after deducting 2 bytes reserved for size
  SERIALIZE_16(tmpShort, (UNSIGNED_SHORT)(bytes-sizeof(UNSIGNED_SHORT)), buf, dummyBytes);

  return bytes;
}
Esempio n. 3
0
/**
 * 把符号标识添加到字符表
 * @param _name 符号标识
 * @param _type 类型(变量、函词、谓词)
 * @param _arity 参数个数
 * @return 符号标识的id
 */
int Vocabulary::addSymbol(const char* _name, SYMBOL_TYPE _type, int _arity )
{
    // return value: 1. >=0 - id; 2. -1 - too many symbols; 3. -2 - _type error
    assert(_name);
    
    int id;
    string name = _name;
    
    if((id = getSymbolId(_name, _type)) < 0) {

        switch (_type) {
        case VARIABLE:
            id = m_nVariableId ++;
            m_mapVariableName[id] = name;
            break;
        case FUNCTION:
            id = m_nFunctionId ++;
            m_mapFunctionName[id] = name;
            m_mapFunctionArity[id] = _arity;
            break;
        case PREDICATE:
            id = m_nPredicateId ++;
            m_mapPredicateName[id] = name;
            m_mapPredicateArity[id] = _arity;
            break;
        default:
            assert(0);
            return -2;
        }
    }
    
    return id;
}
Esempio n. 4
0
/**
 * 设置极少化谓词的优先级
 * @param _sName
 * @param _bIsNewLevel
 */
void Vocabulary::setMininalPredicatePriority(const char* _sName) {
    int predicateId = getSymbolId(_sName, PREDICATE);
    assert(predicateId != -1);
    while (m_nPriIndex >= m_vvMininalPredicates.size()) {
        m_vvMininalPredicates.push_back(vector<int>());
    }
    
    m_vvMininalPredicates[m_nPriIndex].push_back(predicateId);
}
Esempio n. 5
0
int ScripMasterDataRequest::serialize(char *buf)
{
  int bytes = 0;
    UNSIGNED_INTEGER tmp = 0;
    UNSIGNED_SHORT tmpShort = 0;
    UNSIGNED_CHARACTER tmpChar = 0;
    UNSIGNED_LONG tmpLong = 0;

    bytes = sizeof(UNSIGNED_SHORT);  // Leave 2 bytes for packet size
    // Put category of command
    SERIALIZE_8(tmpChar, (UNSIGNED_CHARACTER)(CMD::CommandCategory_SEND_SCRIP_MASTER_DATA), buf, bytes);  //Command Category

    // Put fields of this class
    SERIALIZE_8(tmpChar, getScripMasterDataRequestType(), buf, bytes);
    SERIALIZE_32(tmp, getClientId(), buf, bytes);
    SERIALIZE_64(tmpLong, getRecordNumber(), buf, bytes);
    SERIALIZE_64(tmpLong, getSecurityId(), buf, bytes);
    SERIALIZE_64(tmpLong, getSymbolId(), buf, bytes);
    SERIALIZE_16(tmpShort, getExchangeId(), buf, bytes);

    memcpy(buf + bytes, getSymbol(), SYMBOL_SIZE);
    bytes += SYMBOL_SIZE;
    memcpy(buf + bytes, getSeries(), SERIES_SIZE);
    bytes += SERIES_SIZE;
    memcpy(buf + bytes, getMarketName(), SERIES_SIZE);
    bytes += MARKET_NAME_SIZE;
    SERIALIZE_8(tmpChar, getOptionType(), buf, bytes);
    SERIALIZE_8(tmpChar, getOptionMode(), buf, bytes);
    SERIALIZE_8(tmpChar, getSecurityType(), buf, bytes);
    SERIALIZE_64(tmpLong, getStrikePrice(), buf, bytes);
    SERIALIZE_32(tmp, getExpiryYearMon(), buf, bytes);
    SERIALIZE_32(tmp, getExpiryDate(), buf, bytes);
    SERIALIZE_32(tmp, getNumberOfRecords(), buf, bytes);
    memcpy(buf + bytes, getSymbolAlias(), SYMBOL_ALIAS_SIZE);
    bytes += SYMBOL_ALIAS_SIZE;

    UNSIGNED_SHORT dummyBytes = 0;
    // Put size as the first field after deducting 2 bytes reserved for size
    SERIALIZE_16(tmpShort, (UNSIGNED_SHORT)(bytes-sizeof(UNSIGNED_SHORT)), buf, dummyBytes);

    return bytes;
}
Esempio n. 6
0
    int MDQuoteConsolidated::serialize(char *buf)
    {
        int bytes = 0;
        UNSIGNED_CHARACTER tmpChar = 0;
        UNSIGNED_LONG tmpLong = 0;
        UNSIGNED_SHORT tmpShort = 0;

        bytes = sizeof(UNSIGNED_SHORT);  // Leave 2 bytes for packet size
        SERIALIZE_8(tmpChar, (UNSIGNED_CHARACTER)
                                (RSP::Responsecategory_MDQuoteConsolidated),
                    buf,
                    bytes);  //Response Category

        SERIALIZE_64(tmpLong, getNumberOfSymbols(), buf, bytes);
        for(int i=0; i<getNumberOfSymbols(); ++i)
        {
            SERIALIZE_64(tmpLong, getSymbolId(i), buf, bytes);
            SERIALIZE_64(tmpLong, getLastTradePrice(i), buf, bytes);
            SERIALIZE_64(tmpLong, getLastTradeQty(i), buf, bytes);
            SERIALIZE_64(tmpLong, getOpenPrice(i), buf, bytes);
            SERIALIZE_64(tmpLong, getClosePrice(i), buf, bytes);
            SERIALIZE_64(tmpLong, getHighPrice(i), buf, bytes);
            SERIALIZE_64(tmpLong, getLowPrice(i), buf, bytes);
        }
        SERIALIZE_8(tmpChar, getDepth(), buf, bytes);

        for(int i=0; i<_numSymbols; ++i)
        {
            for(int j=0; j<_depth; ++j)
            {
            SERIALIZE_64(tmpLong, _bidPrice[i][j], buf, bytes);
            SERIALIZE_64(tmpLong, _bidQty[i][j], buf, bytes);
            SERIALIZE_64(tmpLong, _askPrice[i][j], buf, bytes);
            SERIALIZE_64(tmpLong, _askQty[i][j], buf, bytes);
            }
        }
        UNSIGNED_SHORT dummyBytes = 0;
        // Put size as the first field after deducting 2 bytes reserved for size
        SERIALIZE_16(tmpShort, (UNSIGNED_SHORT)(bytes-sizeof(UNSIGNED_SHORT)), buf, dummyBytes);

        return bytes;
    }
Esempio n. 7
0
 void MDQuoteConsolidated::dump()
 {
     std::cout << "\nxxxxxxxxxxxxxxxxxxx MDQuote xxxxxxxxxxxxxxxxxxxxxxxx\n" << std::endl;
     std::cout << "\ngetNumberOfSymbols()       " << getNumberOfSymbols();
     for(int i=0; i<getNumberOfSymbols(); ++i)
     {
         std::cout << "\ngetSymbolId()         " << getSymbolId(i);
         std::cout << "\ngetLastTradePrice() " << getLastTradePrice(i);
         std::cout << "\ngetLastTradeQty()   " << getLastTradeQty(i);
         std::cout << "\ngetOpenPrice()        " << getOpenPrice(i);
         std::cout << "\ngetClosePrice()       " << getClosePrice(i);
         std::cout << "\ngetHighPrice()        " << getHighPrice(i);
         std::cout << "\ngetLowPrice()         " << getLowPrice(i);
         std::cout << "\ngetDepth()              " << (UNSIGNED_INTEGER) getDepth();
         std::cout << "\nBidPrice                  " ; dumpDepth(_bidPrice[i], getDepth());
         std::cout << "\nBidQty                    " ; dumpDepth(_bidQty[i], getDepth());
         std::cout << "\nAskPrice                  " ; dumpDepth(_askPrice[i], getDepth());
         std::cout << "\nAskQty                    " ; dumpDepth(_askQty[i], getDepth());
     }
     std::cout << "\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" << std::endl;
 }
Esempio n. 8
0
int MDQuote::serialize(char *buf)
{
  int bytes = 0;
  UNSIGNED_CHARACTER tmpChar = 0;
  UNSIGNED_LONG tmpLong = 0;
  UNSIGNED_SHORT tmpShort = 0;

  bytes = sizeof(UNSIGNED_SHORT);  // Leave 2 bytes for packet size
  SERIALIZE_8(tmpChar, (UNSIGNED_CHARACTER)(RSP::Responsecategory_MDQuote), buf, bytes);  //Response Category

  SERIALIZE_64(tmpLong, getSymbolId(), buf, bytes);
  SERIALIZE_64(tmpLong, getNumberOfTrades(), buf, bytes);
  SERIALIZE_64(tmpLong, getVolume(), buf, bytes);
  SERIALIZE_64(tmpLong, getValue(), buf, bytes);
  SERIALIZE_64(tmpLong, getLastTradePrice(), buf, bytes);
  SERIALIZE_64(tmpLong, getLastTradeQty(), buf, bytes);
  SERIALIZE_64(tmpLong, getOpenPrice(), buf, bytes);
  SERIALIZE_64(tmpLong, getClosePrice(), buf, bytes);
  SERIALIZE_64(tmpLong, getHighPrice(), buf, bytes);
  SERIALIZE_64(tmpLong, getLowPrice(), buf, bytes);
  SERIALIZE_64(tmpLong, getTotalBidQty(), buf, bytes);
  SERIALIZE_64(tmpLong, getTotalAskQty(), buf, bytes);
  SERIALIZE_64(tmpLong, getLowerCktLimit(), buf, bytes);
  SERIALIZE_64(tmpLong, getUpperCktLimit(), buf, bytes);
  SERIALIZE_8(tmpChar, getDepth(), buf, bytes);
  memcpy(buf+bytes, _bidPrice, QUOTEDATA_LENGTH);
  bytes += QUOTEDATA_LENGTH;
  memcpy(buf+bytes, _bidQty, QUOTEDATA_LENGTH);
  bytes += QUOTEDATA_LENGTH;
  memcpy(buf+bytes, _askPrice, QUOTEDATA_LENGTH);
  bytes += QUOTEDATA_LENGTH;
  memcpy(buf+bytes, _askQty, QUOTEDATA_LENGTH);
  bytes += QUOTEDATA_LENGTH;

  UNSIGNED_SHORT dummyBytes = 0;
  // Put size as the first field after deducting 2 bytes reserved for size
  SERIALIZE_16(tmpShort, (UNSIGNED_SHORT)(bytes-sizeof(UNSIGNED_SHORT)), buf, dummyBytes);
  
  return bytes;
}
Esempio n. 9
0
void ScripMasterDataRequest::dump()
{

  std::cout << "ScripMasterDataRequest dump : " << std::endl;
  std::cout << getScripMasterDataRequestType() << std::endl; 
  std::cout << getClientId() << std::endl; 
  std::cout << getRecordNumber() << std::endl; 
  std::cout << getSecurityId() << std::endl; 
  std::cout << getSymbolId() << std::endl; 
  std::cout << getExchangeId() << std::endl; 
  std::cout << getSymbol() << std::endl; 
  std::cout << getSeries() << std::endl; 
  std::cout << getMarketName() << std::endl; 
  std::cout << getOptionType() << std::endl; 
  std::cout << getOptionMode() << std::endl; 
  std::cout << getSecurityType() << std::endl; 
  std::cout << getStrikePrice() << std::endl; 
  std::cout << getExpiryYearMon() << std::endl; 
  std::cout << getExpiryDate() << std::endl; 
  std::cout << getNumberOfRecords() << std::endl;
  std::cout << getSymbolAlias() << std::endl;
  std::cout << "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" << std::endl;
    
}
Esempio n. 10
0
void MDQuote::dump()
{
  std::cout << "\nxxxxxxxxxxxxxxxxxxx MDQuote xxxxxxxxxxxxxxxxxxxxxxxx\n" << std::endl;
  std::cout << "\ngetSymbolId()       " << getSymbolId();
  std::cout << "\ngetNumberOfTrades() " << getNumberOfTrades();
  std::cout << "\ngetVolume()         " << getVolume();
  std::cout << "\ngetValue()          " << getValue();
  std::cout << "\ngetLastTradePrice() " << getLastTradePrice();
  std::cout << "\ngetLastTradeQty()   " << getLastTradeQty();
  std::cout << "\ngetOpenPrice()      " << getOpenPrice();
  std::cout << "\ngetClosePrice()     " << getClosePrice();
  std::cout << "\ngetHighPrice()      " << getHighPrice();
  std::cout << "\ngetLowPrice()       " << getLowPrice();
  std::cout << "\ngetTotalBidQty()    " << getTotalBidQty();
  std::cout << "\ngetTotalAskQty()    " << getTotalAskQty();
  std::cout << "\ngetLowerCktLimit()  " << getLowerCktLimit();
  std::cout << "\ngetUpperCktLimit()  " << getUpperCktLimit();
  std::cout << "\ngetDepth()          " << (UNSIGNED_INTEGER) getDepth();
  std::cout << "\nBidPrice            " ; dumpDepth(_bidPrice, getDepth());
  std::cout << "\nBidQty              " ; dumpDepth(_bidQty, getDepth());
  std::cout << "\nAskPrice            " ; dumpDepth(_askPrice, getDepth());
  std::cout << "\nAskQty              " ; dumpDepth(_askQty, getDepth());
  std::cout << "\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" << std::endl;
}
Esempio n. 11
0
	void SymbolManager::registerChartScript(ChartScript * chartScript)
	{
		int id = getSymbolId(chartScript->getSymbol());
		chartScript->setSymbolID(id);
		symbol2ChartScriptMap[id].push_back(chartScript);
	}
Esempio n. 12
0
int32_t Bytecode_getSymbolId(ILBytecode* bc, wchar_t* wstr) {
	return getSymbolId(bc->symbols, wstr);
}
Esempio n. 13
0
/**
 * 保存可变谓词
 * @param _name
 */
void Vocabulary::addVaryPredicate(const char* _name) {
    int id = getSymbolId(_name, PREDICATE);
    m_mapIsVaryPredicate[id] = true;
}