Esempio n. 1
0
PHP_METHOD(BatchStatement, __construct)
{
  zval *type = NULL;
  cassandra_statement *self = NULL;

  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &type) == FAILURE) {
    return;
  }

  self = PHP_CASSANDRA_GET_STATEMENT(getThis());

  if (type) {
    if (Z_TYPE_P(type) != IS_LONG) {
      INVALID_ARGUMENT(type, "one of Cassandra::BATCH_TYPE_*");
    }

    switch (Z_LVAL_P(type)) {
    case CASS_BATCH_TYPE_LOGGED:
    case CASS_BATCH_TYPE_UNLOGGED:
    case CASS_BATCH_TYPE_COUNTER:
      self->batch_type = (CassBatchType) Z_LVAL_P(type);
      break;
    default:
      INVALID_ARGUMENT(type, "one of Cassandra::BATCH_TYPE_*");
    }
  }
}
Esempio n. 2
0
void CMTDHistory::SetCoordinate(unsigned int id,
                                const CSmallString& name,
                                const CSmallString& type,
                                double min_value,double max_value,unsigned int nbins)
{
    if( Sizes == NULL ){
        RUNTIME_ERROR("Sizes is NULL");
    }
    if( id < 0 || id >= NCoords ){
        INVALID_ARGUMENT("id out-of-range");
    }

    if( nbins <= 0 ){
        INVALID_ARGUMENT("nbins <= 0");
    }
    if( max_value < min_value ){
        INVALID_ARGUMENT("max_value < min_value");
    }

    if(Buffers.NumOfMembers() > 0) {
        // it was already finalized - destroy data
        Deallocate();
    }

    Sizes[id].Type = type;
    Sizes[id].Name = name;

    Sizes[id].MinValue = min_value;
    Sizes[id].MaxValue = max_value;

    Sizes[id].NBins = nbins;
    Sizes[id].BinWidth = (Sizes[id].MaxValue - Sizes[id].MinValue)/Sizes[id].NBins;
    Sizes[id].Width = Sizes[id].MaxValue - Sizes[id].MinValue;
}
Esempio n. 3
0
void
php_cassandra_date_init(INTERNAL_FUNCTION_PARAMETERS)
{
    zval *seconds = NULL;
    cassandra_date *self;

    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &seconds) == FAILURE) {
        return;
    }

    if (getThis() && instanceof_function(Z_OBJCE_P(getThis()), cassandra_date_ce TSRMLS_CC)) {
        self = PHP_CASSANDRA_GET_DATE(getThis());
    } else {
        object_init_ex(return_value, cassandra_date_ce);
        self = PHP_CASSANDRA_GET_DATE(return_value);
    }

    if (seconds == NULL) {
        self->date = cass_date_from_epoch(time(NULL));
    } else {
        if (Z_TYPE_P(seconds) != IS_LONG) {
            INVALID_ARGUMENT(seconds, "a number of seconds since the Unix Epoch");
        }
        self->date = cass_date_from_epoch(Z_LVAL_P(seconds));
    }
}
Esempio n. 4
0
int CLapack::syev(char jobz,char uplo,CFortranMatrix& a,CVector& w)
{
    int     info = 0;
    int     nrows = a.GetNumberOfRows();
    int     nwork = -1;
    double  twork[1];

    // query workspace length
    dsyev_(&jobz,&uplo,&nrows,a.GetRawDataField(),&nrows,w.GetRawDataField(),
           twork,&nwork,&info);

    if( info != 0 ){
        CSmallString error;
        error << "unable to determine lwork, info = " << info;
        INVALID_ARGUMENT(error);
    }

    // allocate work space
    CVector work;
    nwork = static_cast<int>(twork[0]) + 1;
    work.CreateVector(nwork);

    // run again
    dsyev_(&jobz,&uplo,&nrows,a.GetRawDataField(),&nrows,w.GetRawDataField(),
           work.GetRawDataField(),&nwork,&info);

    return(info);
}
Esempio n. 5
0
void CBead::SaveInfo(CXMLElement* p_ele)
{
    if(p_ele == NULL) {
        INVALID_ARGUMENT("p_ele is NULL");
    }

    p_ele->SetAttribute("bead_id",BeadID);
    p_ele->SetAttribute("client_id",ClientID);
    p_ele->SetAttribute("permanent",Permanent);
    p_ele->SetAttribute("mode",Mode);
    p_ele->SetAttribute("nupd",NumOfUpdates);

    // save position
    CXMLBinData* p_posele = p_ele->CreateChildBinData("POS");
    Pos.Save(p_posele);

    CXMLBinData* p_pmfele = p_ele->CreateChildBinData("PMF");
    PMF.Save(p_pmfele);

    CXMLBinData* p_ppmfele = p_ele->CreateChildBinData("pPMF");
    pPMF.Save(p_ppmfele);

    CXMLBinData* p_rposele = p_ele->CreateChildBinData("RPOS");
    RPos.Save(p_rposele);
}
Esempio n. 6
0
void
SessionImpl::AddInputDirectory (/*[in]*/ const char *	lpszPath,
				/*[in]*/ bool		atEnd)
{
  MIKTEX_ASSERT_STRING (lpszPath);

  if (! Utils::IsAbsolutePath(lpszPath))
    {
      INVALID_ARGUMENT ("SessionImpl::AddInputDirectory", lpszPath);
    }

  // clear the search path cache
  ClearSearchVectors ();

  if (atEnd)
    {
      inputDirectories.push_back (lpszPath);
    }
  else
    {
      inputDirectories.push_front (lpszPath);
    }

#if 1
  SetCWDEnv ();
#endif
}
Esempio n. 7
0
void CSTMClient::SetCoord(int id,const CSmallString& name,const CSmallString& type)
{
    if((id < 0) || (id >= NumOfCVs)) {
        INVALID_ARGUMENT("cv id is out of range");
    }

    CVs[id].SetCoord(id,name,type);
}
Esempio n. 8
0
void CSTMClient::SetNumberOfItems(int nitems)
{
    if(nitems <= 0) {
        INVALID_ARGUMENT("number of items has to be grater than zero");
    }

    CVs.CreateVector(nitems);
    NumOfCVs = nitems;
}
Esempio n. 9
0
void CClient::ExecuteCommand(CClientCommand* p_command,bool async)
{
    if( p_command == NULL ){
        INVALID_ARGUMENT("p_command is NULL");
    }

    bool is_in_list;

    CommandListMutex.Lock();
        is_in_list = Commands.IsInList(p_command);
    CommandListMutex.Unlock();

    if( is_in_list == true ) {
        LOGIC_ERROR("command is already in command queue");
    }

    if( p_command->Client != this ) {
        LOGIC_ERROR("wrong side");
    }

    // add AUTH element -----------------------------
    CXMLElement* p_cele = p_command->GetCommandElementByPath("AUTH",true);
    p_cele->SetAttribute("password",ActionRequest.GetPassword());
    p_cele->SetAttribute("protocol",ActionRequest.GetProtocolName());

    // now start thread -----------------------------
    CommandListMutex.Lock();
        try {
            NumOfExecutedCommands++;
            Commands.InsertToEnd(p_command);
        } catch(...) {
            CommandListMutex.Unlock();
            throw;
        }
    CommandListMutex.Unlock();

    // start command processing
    if( p_command->StartThread() == false ) {
        CommandListMutex.Lock();
            Commands.Remove(p_command);
        CommandListMutex.Unlock();
        RUNTIME_ERROR("unable to start command thread");
    }

    if( async == true ) return;  // return immediatelly

    // wait until command thread is terminated
    p_command->WaitForThread();

    // ExecutedCommand is now NULL !!!
    if( p_command->GetStatus() != ECS_FINISHED ) {
        RUNTIME_ERROR("command was not completed");
    }
    if( p_command->GetMainReturnValue() == false ) {
        RUNTIME_ERROR("server did not process command successfully");
    }
}
Esempio n. 10
0
void CMTDHistory::ReadMTDData(CXMLElement* p_ele)
{
    if(p_ele == NULL) {
        INVALID_ARGUMENT("p_ele is NULL");
    }

// destroy previous data
    Deallocate();

// read new one
    AddMTDData(p_ele);
}
Esempio n. 11
0
void CSTMClient::SaveCVSInfo(CXMLElement* p_ele)
{
    if(p_ele == NULL) {
        INVALID_ARGUMENT("p_tele is NULL");
    }

    p_ele->SetAttribute("ncvs",NumOfCVs);

    for(int i=0; i < NumOfCVs; i++) {
        CXMLElement* p_iele = p_ele->CreateChildElement("COORD");
        CVs[i].SaveInfo(p_iele);
    }
}
Esempio n. 12
0
void CClient::InitCommand(CClientCommand* p_cmd,const COperation& operation)
{
    if( p_cmd == NULL ){
        INVALID_ARGUMENT("p_cmd is NULL");
    }
    // is it fresh command?
    if( p_cmd->GetStatus() != ECS_NEW ){
        LOGIC_ERROR("command does not have status ECS_NEW");
    }

    // init command
    p_cmd->SetClient(this);
    p_cmd->SetOperation(operation);
    p_cmd->DebugMode = DebugMode;
}
Esempio n. 13
0
PHP_METHOD(Rows, offsetExists)
{
  zval* offset;
  cassandra_rows* self = NULL;

  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &offset) == FAILURE)
    return;

  if (Z_TYPE_P(offset) != IS_LONG || Z_LVAL_P(offset) < 0) {
    INVALID_ARGUMENT(offset, "a positive integer");
  }

  self = (cassandra_rows*) zend_object_store_get_object(getThis() TSRMLS_CC);

  RETURN_BOOL(zend_hash_index_exists(Z_ARRVAL_P(self->rows), (ulong) Z_LVAL_P(offset)));
}
Esempio n. 14
0
void CMTDHistory::SaveCVSInfo(CXMLElement* p_iele)
{
    if(p_iele == NULL) {
        INVALID_ARGUMENT("p_iele is NULL");
    }

    CXMLElement* p_ele = p_iele->CreateChildElement("CVS");
    p_ele->SetAttribute("nitems",NCoords);

    CColVariable*  p_coord;

    for(unsigned int i=0; i < NCoords; i++) {
        CXMLElement* p_iele = p_ele->CreateChildElement("COORD");
        p_coord = &Sizes[i];
        p_coord->SaveInfo(p_iele);
    }
}
Esempio n. 15
0
int CLapack::gelsd(CFortranMatrix& a,CVector& rhs,double rcond,int& rank)
{
    int m = a.GetNumberOfRows();
    int n = a.GetNumberOfColumns();
    int nrhs = 1;
    int lda = m;
    int ldb = std::max(m,n);

    CVector s;
    int     ns = std::min(m,n);
    s.CreateVector(ns);

    int info = 0;

    // query work size
    int     lwork = -1;
    double  twork[1];

    // printf("lwork = %d\n",lwork);

    CSimpleVector<int>  iwork;
    int li = 3*std::min(m,n)*std::min(m,n) + 11*std::min(m,n);
    iwork.CreateVector(li);

    dgelsd_(&m,&n,&nrhs,a.GetRawDataField(),&lda,rhs.GetRawDataField(),&ldb,s.GetRawDataField(),
            &rcond,&rank,twork,&lwork,iwork.GetRawDataField(),&info);

    if( info != 0 ){
        CSmallString error;
        error << "unable to determine lwork, info = " << info;
        INVALID_ARGUMENT(error);
    }

    lwork = static_cast<int>(twork[0]) + 1;

    // printf("lwork = %d\n",lwork);

    CSimpleVector<double>  work;
    work.CreateVector(lwork);

    // run svd
    dgelsd_(&m,&n,&nrhs,a.GetRawDataField(),&lda,rhs.GetRawDataField(),&ldb,s.GetRawDataField(),
            &rcond,&rank,work.GetRawDataField(),&lwork,iwork.GetRawDataField(),&info);

    return(info);
}
Esempio n. 16
0
PHP_METHOD(Rows, offsetGet)
{
  zval*  offset;
  zval** value;
  cassandra_rows* self = NULL;

  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &offset) == FAILURE)
    return;

  if (Z_TYPE_P(offset) != IS_LONG || Z_LVAL_P(offset) < 0) {
    INVALID_ARGUMENT(offset, "a positive integer");
  }

  self = (cassandra_rows*) zend_object_store_get_object(getThis() TSRMLS_CC);

  if (zend_hash_index_find(Z_ARRVAL_P(self->rows), (ulong) Z_LVAL_P(offset), (void**) &value) == SUCCESS)
    RETURN_ZVAL(*value, 1, 0);
}
Esempio n. 17
0
bool
SessionImpl::GetNextFileTypeInfo (/*[in]*/ unsigned		index,
        /*[out]*/ FileTypeInfo &	fileTypeInfo)
{
    // skip FileType::None
    unsigned index1 = index + 1;
    if (index1 == FileType::E_N_D)
    {
        return (false);
    }
    if (index1 > FileType::E_N_D)
    {
        INVALID_ARGUMENT ("SessionImpl::GetNextFileTypeInfo",
                          NUMTOSTR(index));
    }
    fileTypeInfo = GetFileTypeInfo(static_cast<FileType::EnumType>(index1));
    return (true);
}
Esempio n. 18
0
CMTDBuffer* CMTDServerHist::AddBuffer(CXMLElement* p_ele)
{
    if(p_ele == NULL) {
        INVALID_ARGUMENT("p_ele is NULL");
    }

    CMTDBuffer* p_buffer;

    HistMutex.Lock();
        try {
            p_buffer = AddMTDDataAsSingleBuffer(p_ele);
        } catch(...) {
            HistMutex.Unlock();
            throw;
        }
    HistMutex.Unlock();

    return(p_buffer);
}
Esempio n. 19
0
void CBead::LoadInfo(CXMLElement* p_ele)
{
    if(p_ele == NULL) {
        INVALID_ARGUMENT("p_ele is NULL");
    }

    bool result = true;
    result &= p_ele->GetAttribute("bead_id",BeadID);
    result &= p_ele->GetAttribute("client_id",ClientID);
    result &= p_ele->GetAttribute("permanent",Permanent);
    result &= p_ele->GetAttribute("mode",Mode);
    result &= p_ele->GetAttribute("nupd",NumOfUpdates);  

    if(result == false) {
        LOGIC_ERROR("unable to read some attributes");
    }

    // load positions
    CXMLBinData* p_posele = p_ele->GetFirstChildBinData("POS");
    if(p_posele == NULL) {
        LOGIC_ERROR("unable to open POS element");
    }
    Pos.Load(p_posele);

    CXMLBinData* p_pmfele = p_ele->GetFirstChildBinData("PMF");
    if(p_pmfele == NULL) {
        LOGIC_ERROR("unable to open PMF element");
    }
    PMF.Load(p_pmfele);

    CXMLBinData* p_ppmfele = p_ele->GetFirstChildBinData("pPMF");
    if(p_ppmfele == NULL) {
        LOGIC_ERROR("unable to open pPMF element");
    }
    pPMF.Load(p_ppmfele);

    CXMLBinData* p_rposele = p_ele->GetFirstChildBinData("RPOS");
    if(p_rposele == NULL) {
        LOGIC_ERROR("unable to open RPOS element");
    }
    RPos.Load(p_rposele);
}
Esempio n. 20
0
void CMTDHistory::AddMTDData(CXMLElement* p_ele)
{
    if(p_ele == NULL) {
        INVALID_ARGUMENT("p_ele is NULL");
    }

    CXMLElement* p_history = p_ele->GetFirstChildElement("HISTORY");
    if(p_history == NULL) {
        LOGIC_ERROR("unable to open HISTORY element");
    }

    unsigned int num_of_hills; // this is total number of hills

    if(p_history->GetAttribute("numofhills",num_of_hills) == false) {
        LOGIC_ERROR("unable to get number of hills");
    }

    if(num_of_hills == 0) return;   // there are no data in received history

    CXMLBinData* p_hele = p_history->GetFirstChildBinData("BUFFER");

    unsigned int control_num_of_hills = 0;

    while(p_hele != NULL) {
        unsigned int num_of_values;
        if(p_hele->GetAttribute("numofhills",num_of_values) == false) {
            LOGIC_ERROR("unable to get number of hills in buffer");
        }

        control_num_of_hills += num_of_values;

        // now allocate buffer
        CMTDBuffer* p_buffer = GetNewBuffer(num_of_values);
        p_buffer->ReadBufferData(p_hele);

        p_hele = p_hele->GetNextSiblingBinData("BUFFER");
    }

    if(control_num_of_hills != num_of_hills) {
        LOGIC_ERROR("mismatch in number of hills");
    }
}
Esempio n. 21
0
void CMatrix::CreateMatrix(long unsigned int rows,long unsigned int columns)
{
    if( (rows < 0) || (columns < 0) ){
        INVALID_ARGUMENT("(rows < 0) || (columns < 0)");
    }

    if(Rows > 0) {
        FreeMatrix();
    }
    if( (rows == 0) || (columns == 0) ) return;

    RowVectors = new CVector[rows];

    for(long unsigned int i=0; i < rows; i++ ) {
        RowVectors[i].CreateVector(columns);
    }

    Rows = rows;
    Columns = columns;
}
Esempio n. 22
0
void CBead::GetProductionData(CXMLElement* p_ele)
{
    if(p_ele == NULL) {
        INVALID_ARGUMENT("p_ele is NULL");
    }

    Pos = RPos;
    CXMLBinData* p_pmfele = p_ele->GetFirstChildBinData("PMF");
    if(p_pmfele == NULL) {
        LOGIC_ERROR("unable to open PMF element");
    }
    PMF.Load(p_pmfele);

    CXMLBinData* p_mtzele = p_ele->GetFirstChildBinData("MTZ");
    if(p_mtzele == NULL) {
        LOGIC_ERROR("unable to open MTZ element");
    }
    MTZ.Load(p_mtzele);

    ModeStatus = BMS_FINISHED;
}
Esempio n. 23
0
PHP_METHOD(BatchStatement, add)
{
  zval *statement = NULL;
  zval *arguments = NULL;
  cassandra_batch_statement_entry *batch_statement_entry = NULL;
  cassandra_statement *self = NULL;

#if PHP_MAJOR_VERSION >= 7
  zval entry;
#endif

  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &statement, &arguments) == FAILURE) {
    return;
  }

  if (!instanceof_function(Z_OBJCE_P(statement), cassandra_simple_statement_ce TSRMLS_CC) &&
      !instanceof_function(Z_OBJCE_P(statement), cassandra_prepared_statement_ce TSRMLS_CC)) {
    INVALID_ARGUMENT(statement, "an instance of Cassandra\\SimpleStatement or Cassandra\\PreparedStatement");
  }

  self = PHP_CASSANDRA_GET_STATEMENT(getThis());

  batch_statement_entry = (cassandra_batch_statement_entry *) ecalloc(1, sizeof(cassandra_batch_statement_entry));

  PHP5TO7_ZVAL_COPY(PHP5TO7_ZVAL_MAYBE_P(batch_statement_entry->statement), statement);

  if (arguments) {
    PHP5TO7_ZVAL_COPY(PHP5TO7_ZVAL_MAYBE_P(batch_statement_entry->arguments), arguments);
  }


#if PHP_MAJOR_VERSION >= 7
  ZVAL_PTR(&entry, batch_statement_entry);
  zend_hash_next_index_insert(&self->statements, &entry);
#else
  zend_hash_next_index_insert(&self->statements,
                              &batch_statement_entry, sizeof(cassandra_batch_statement_entry *),
                              NULL);
#endif
}
Esempio n. 24
0
void CMTDServerHist::GetData(CServerCommand* p_command)
{
    if(p_command == NULL) {
        INVALID_ARGUMENT("p_command is NULL");
    }

    CXMLElement* p_result = p_command->GetRootResultElement();

    HistMutex.Lock();

        try {
            SaveCVSInfo(p_result);
            if(GetNumberOfCoords() > 0) {
                WriteMTDData(p_result);
            }
        } catch(...){
            HistMutex.Unlock();
            throw;
        }

    HistMutex.Unlock();
}
Esempio n. 25
0
bool
SessionImpl::GetWorkingDirectory (/*[in]*/ unsigned	n,
				  /*[out]*/ PathName &	path)
{
  if (n == scratchDirectories.size() + inputDirectories.size())
  {
    return (false);
  }
  if (n > scratchDirectories.size() + inputDirectories.size())
  {
    INVALID_ARGUMENT ("GetWorkingDirectory", NUMTOSTR(n));
  }
  if (n < scratchDirectories.size())
  {
    path = scratchDirectories[scratchDirectories.size() - n - 1];
  }
  else
  {
    path = inputDirectories[n - scratchDirectories.size()];
  }
  return (true);
}
Esempio n. 26
0
void CMTDRegClient::ExchangeDataWithClient(CServerCommand* p_command)
{
    if(p_command == NULL) {
        INVALID_ARGUMENT("p_command is NULL");
    }

    CXMLElement* p_cele = p_command->GetRootCommandElement();
    CXMLElement* p_rele = p_command->GetRootResultElement();

    ClientMutex.Lock();
        try {
            // add received data as new buffer to the history
            CMTDBuffer* p_buffer = MTDServer.MTDHistory.AddBuffer(p_cele);

            p_buffer->SetLevel(GetClientID());

            // now register this buffer for all other clients
            int numofclients = MTDServer.RegClients.GetNumberOfRegClients();

            for(int i=0; i < numofclients; i++) {
                CMTDRegClient* p_client = dynamic_cast<CMTDRegClient*>(MTDServer.RegClients.GetClient(i));
                if((p_client != NULL) && (p_client != this)) {
                    p_client->RegisterBuffer(p_buffer);
                }
            }

            // write new data from other clients
            MTDServer.MTDHistory.WriteMTDData(p_rele,NewBuffers);

            // remove registered buffers
            NewBuffers.RemoveAll();

        } catch(...) {
            ClientMutex.Unlock();
            throw;
        }

    ClientMutex.Unlock();
}
Esempio n. 27
0
void CBead::SetNextStepData(CXMLElement* p_ele)
{
    if( ModeStatus != BMS_PREPARED ){
        CSmallString error;
        error << "bead ID=" << BeadID << " is not in preapred mode, unable to set data for exchange";
        RUNTIME_ERROR(error);
    }

    if(p_ele == NULL) {
        INVALID_ARGUMENT("p_ele is NULL");
    }

    // program
    p_ele->SetAttribute("mode",GetMode());
    p_ele->SetAttribute("steps",GetModeLength());

    // and bead position
    CXMLBinData* p_bposele = p_ele->CreateChildBinData("BPOS");
    RPos.Save(p_bposele);

    ModeStatus = BMS_RUNNING;
}
Esempio n. 28
0
void CMTDHistory::LoadCVSInfo(CXMLElement* p_iele)
{
    if(p_iele == NULL) {
        INVALID_ARGUMENT("p_iele is NULL");
    }

    Deallocate();

    CXMLElement* p_ele = p_iele->GetFirstChildElement("CVS");

    if(p_ele == NULL) {
        LOGIC_ERROR("unable to get CVS element");
    }

    bool result = true;

    int lnitems;
    result &= p_ele->GetAttribute("nitems",lnitems);

    if(result == false) {
        LOGIC_ERROR("unable to get header attributes");
    }

    SetNumberOfCoords(lnitems);

    CXMLElement*   p_cel = NULL;
    if(p_ele != NULL) p_cel = p_ele->GetFirstChildElement("COORD");
    unsigned int   ccount = 0;

    while(p_cel != NULL) {
        if(ccount >= NCoords) {
            LOGIC_ERROR("more COORD elements than NCoords");
        }
        Sizes[ccount].LoadInfo(p_cel);
        ccount++;
        p_cel = p_cel->GetNextSiblingElement("COORD");
    }
}
Esempio n. 29
0
void CMTDRegClient::GetInitialData(CServerCommand* p_command)
{
    if(p_command == NULL) {
        INVALID_ARGUMENT("p_command is NULL");
    }

    CXMLElement* p_rele = p_command->GetRootResultElement();

    ClientMutex.Lock();

        try {
            // write new data
            MTDServer.MTDHistory.WriteMTDData(p_rele,NewBuffers);

            // remove registered buffers
            NewBuffers.RemoveAll();
        } catch(...) {
            ClientMutex.Unlock();
            throw;
        }

    ClientMutex.Unlock();
}
Esempio n. 30
0
void CMTDHistory::WriteMTDData(CXMLElement* p_ele,const CSimpleList<CMTDBuffer>& list) const
{
    if(p_ele == NULL) {
        INVALID_ARGUMENT("p_ele is NULL");
    }

    CXMLElement* p_history = p_ele->CreateChildElement("HISTORY");

    unsigned int num_of_hills = GetNumberOfHills(list);

    p_history->SetAttribute("numofhills",num_of_hills);

    if(num_of_hills == 0) return;   // there are no data to transmit

    CSimpleIteratorC<CMTDBuffer>  I(list);
    const CMTDBuffer*             p_buf;

    while((p_buf = I.Current())!= NULL) {
        CXMLBinData* p_bele = p_history->CreateChildBinData("BUFFER");
        p_buf->WriteBufferData(p_bele);
        I++;
    }
}