252
252
// The user has entered one or more new symbols. UserLog object will
253
253
// pass us the pointer to the current alphabet that is being used.
254
254
void CUserLogTrial::AddSymbols(Dasher::VECTOR_SYMBOL_PROB* vpNewSymbolProbs,
255
eUserLogEventType iEvent,
256
Dasher::CAlphabet* pCurrentAlphabet)
255
eUserLogEventType iEvent)
258
//CFunctionLogger f1("CUserLogTrial::AddSymbols", g_pLogger);
260
if (pCurrentAlphabet == NULL)
262
g_pLogger->Log("CUserLogTrial::AddSymbols, pCurrentAlphabet was NULL!", logNORMAL);
265
if (vpNewSymbolProbs == NULL)
267
g_pLogger->Log("CUserLogTrial::AddSymbols, vectorNewSymbolProbs was NULL!", logNORMAL);
271
Dasher::VECTOR_SYMBOL_PROB_DISPLAY* pVectorAdded = NULL;
272
pVectorAdded = new Dasher::VECTOR_SYMBOL_PROB_DISPLAY;
274
if (pVectorAdded == NULL)
276
g_pLogger->Log("CUserLogTrial::AddSymbols, failed to create pVectorAdded!", logNORMAL);
280
for (unsigned int i = 0; i < vpNewSymbolProbs->size(); i++)
282
Dasher::SymbolProb sNewSymbolProb = (Dasher::SymbolProb) (*vpNewSymbolProbs)[i];
284
Dasher::SymbolProbDisplay sNewSymbolProbDisplay;
286
sNewSymbolProbDisplay.sym = sNewSymbolProb.sym;
287
sNewSymbolProbDisplay.prob = sNewSymbolProb.prob;
288
sNewSymbolProbDisplay.strDisplay = pCurrentAlphabet->GetText(sNewSymbolProb.sym);
290
pVectorAdded->push_back(sNewSymbolProbDisplay);
292
// Add this symbol to our running total of symbols.
293
// We track the symbols and not the display text
294
// since we may need to delete symbols later and
295
// a given symbol might take up multiple chars.
296
// We also keep the probability around so we can
297
// calculate the average bits of the history.
298
m_vHistory.push_back(sNewSymbolProbDisplay);
257
// Add the symbols to our running total of symbols.
259
// ACL: Old comment said "We track the symbols and not the display text
260
// since we may need to delete symbols later and
261
// a given symbol might take up multiple chars."
262
// - yet stored the display text????
264
// We also keep the probability around so we can
265
// calculate the average bits of the history.
266
m_vHistory.insert(m_vHistory.end(), vpNewSymbolProbs->begin(), vpNewSymbolProbs->end());
301
268
StopPreviousTimer();
315
282
pLocation->avgBits = GetHistoryAvgBits();
316
283
pLocation->event = iEvent;
317
284
pLocation->numDeleted = 0;
318
pLocation->pVectorAdded = pVectorAdded;
285
pLocation->pVectorAdded = new std::vector<Dasher::SymbolProb>(*vpNewSymbolProbs);
320
287
NavCycle* pCycle = GetCurrentNavCycle();
321
288
if (pCycle != NULL)
646
613
strResult += m_szTempBuffer;
647
614
strResult += "</NumAdded>\n";
649
Dasher::VECTOR_SYMBOL_PROB_DISPLAY* pVectorAdded = pLocation->pVectorAdded;
616
Dasher::VECTOR_SYMBOL_PROB* pVectorAdded = pLocation->pVectorAdded;
651
618
if (pVectorAdded != NULL)
653
620
// Output the details of each add
654
621
for (unsigned int j = 0; j < pVectorAdded->size(); j++)
656
Dasher::SymbolProbDisplay sItem = (Dasher::SymbolProbDisplay) (*pVectorAdded)[j];
623
Dasher::SymbolProb sItem = (Dasher::SymbolProb) (*pVectorAdded)[j];
658
625
strResult += strPrefix;
659
626
strResult += "\t<Add>\n";
1262
1229
// Handle the multiple <Add> tags that might exist
1263
1230
vAdded = XMLUtil::GetElementStrings("Add", *iter2);
1264
pLocation->pVectorAdded = new Dasher::VECTOR_SYMBOL_PROB_DISPLAY;
1231
pLocation->pVectorAdded = new Dasher::VECTOR_SYMBOL_PROB;
1266
1233
for (VECTOR_STRING_ITER iter3 = vAdded.begin(); iter3 < vAdded.end(); iter3++)
1268
Dasher::SymbolProbDisplay sAdd;
1270
sAdd.prob = XMLUtil::GetElementFloat("Prob", *iter3);
1271
sAdd.strDisplay = XMLUtil::GetElementString("Text", *iter3);
1272
sAdd.sym = 0; // We don't have the original integer symbol index
1235
Dasher::SymbolProb sAdd(0, // We don't have the original integer symbol index
1236
XMLUtil::GetElementString("Text", *iter3),
1237
XMLUtil::GetElementFloat("Prob", *iter3));
1274
1239
if (pLocation->pVectorAdded != NULL)
1275
1240
pLocation->pVectorAdded->push_back(sAdd);