本文整理汇总了C++中DataReader::read方法的典型用法代码示例。如果您正苦于以下问题:C++ DataReader::read方法的具体用法?C++ DataReader::read怎么用?C++ DataReader::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataReader
的用法示例。
在下文中一共展示了DataReader::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read
void GeodesicProvider::read(DataReader &reader) {
reader.read(this->m_source_vertices);
reader.read(this->m_target_vertices);
reader.read(this->m_algorithm_option);
reader.read(this->m_subdivision_level);
reader.read(this->m_geodesics);
}
示例2: read
void SamplingProvider::read(DataReader &reader) {
reader.read(this->m_sampling_radius);
reader.read(this->m_curvatures);
reader.read(this->m_barycentric_areas);
reader.read(this->m_geodesics);
reader.read(this->m_samples);
}
示例3: init
void Observer::init(DataReader& reader)
{
static const Card defaultCard(SUIT_LAST, RANK_LAST);
reader.read(mGameCards, defaultCard);
reader.read(mGameCardsCount);
reader.read(mTrumpSuit);
unsigned int playerAmount;
reader.read(playerAmount);
while (playerAmount--) {
unsigned int playerIndex;
reader.read(playerIndex);
unsigned int cardsAmount;
reader.read(cardsAmount);
mPlayersCards[mPlayers[playerIndex]] = cardsAmount;
}
unsigned int rounds;
reader.read(rounds);
while (rounds--) {
RoundData* roundData = new RoundData();
loadRoundData(reader, *roundData);
mRoundsData.push_back(roundData);
}
reader.read(mCurrentRoundIndex);
mRestored = true;
bool currentRoundDataExist;
reader.read(currentRoundDataExist);
if (currentRoundDataExist) {
mCurrentRoundData = new RoundData();
loadRoundData(reader, *mCurrentRoundData);
}
}
示例4: loadRoundData
void Observer::loadRoundData(DataReader& reader, RoundData& roundData){
unsigned int players;
reader.read(players);
while (players--) {
unsigned int playerIndex;
reader.read(playerIndex);
roundData.mPlayers.push_back(mPlayers[playerIndex]);
}
loadMap(reader, roundData.mDroppedCards);
loadMap(reader, roundData.mPickedUpCards);
}
示例5: loadMap
void Observer::loadMap(DataReader& reader, std::map<const PlayerId*, CardSet>& map)
{
static const Card defaultCard(SUIT_LAST, RANK_LAST);
unsigned int mapSize;
reader.read(mapSize);
while (mapSize--) {
unsigned int playerIndex;
reader.read(playerIndex);
CardSet cards;
reader.read(cards, defaultCard);
map[mPlayers[playerIndex]] = cards;
}
}
示例6: readInit
void ClientSocket::readInit(DataReader r)
{
g.id = r.readInt();
cout<<"got ID "<<g.id<<'\n';
int w=r.readInt(), h=r.readInt();
Area& a=g.area;
a.w=w,a.h=h;
a.a = new int[w*h];
r.read(a.a, 4*w*h);
int b = r.readInt();
a.bases.resize(b);
r.read(&a.bases[0], 4*b);
cout<<"got map "<<a.w<<' '<<a.h<<'\n';
}
示例7: tick
int
main(void)
{
DataReader reader;
std::vector<fv_t> data;
std::vector<fv_t> test_data;
std::vector<label_t> labels;
std::vector<label_t> test_labels;
category_index_t category_index;
NearestCentroidClassifier centroid_classifier;
TFIDFTransformer tfidf;
long t = tick();
long t_all = tick();
Evaluation evaluation;
if (!reader.open(TRAIN_DATA)) {
fprintf(stderr, "cant read file\n");
return -1;
}
reader.read(data, labels);
printf("read %ld, %ld, %ldms\n", data.size(), labels.size(), tick() - t);
reader.close();
t = tick();
srand(VT_SEED);
build_category_index(category_index, data, labels);
split_data(test_data, test_labels, data, labels, category_index, 0.05f);
build_category_index(category_index, data, labels);
printf("split train:%ld, test:%ld\n", data.size(), test_data.size());
t = tick();
tfidf.train(data);
tfidf.transform(data);
tfidf.transform(test_data);
centroid_classifier.train(category_index, data);
printf("build index %ldms\n", tick() -t );
t = tick();
#ifdef _OPENMP
#pragma omp parallel for schedule(dynamic, 1)
#endif
for (int i = 0; i < (int)test_data.size(); ++i) {
std::vector<int> topn_labels;
centroid_classifier.predict(topn_labels, K, test_data[i]);
#ifdef _OPENMP
#pragma omp critical
#endif
{
evaluation.update(topn_labels, test_labels[i]);
if (i % 1000 == 0) {
print_evaluation(evaluation, i, t);
t = tick();
}
}
}
printf("----\n");
print_evaluation(evaluation, test_data.size(), t_all);
return 0;
}
示例8: readBullet
void ClientSocket::readBullet(DataReader r)
{
Bullet b;
r.read(&b,sizeof(Bullet));
double vol = distvol(length(g.player->loc-b.origin));;
if (b.type==ROCKET) {
}else if (b.type==SHOTGUN)
{
sounds.push_back(Sound(SHOTGUNSOUND, vol));
}else if(b.type==BOUNCEGUN)
{
sounds.push_back(Sound(MACHINEGUNSOUND,vol));
}else if(b.type==MACHINEGUN)//MACHINEGUN == FLAMEGUN
{
//if(-lastFlame+timef()>0.4){
sounds.push_back(Sound(FLAMESOUND,vol));
//lastFlame=timef();
//}
} else if (b.type==RAILGUN) {
sounds.push_back(Sound(RAILSOUND,vol));
}
g.bullets_map.insert(b);
//g.bullets.push_back(*(Bullet*)r.cur);
//g.bulletIndex[g.bullets.back().id] = g.bullets.size()-1;
}
示例9: pushDataPacket
void Listener::pushDataPacket(DataReader& reader) {
if (!_pDataWriter && !init())
return;
if(publication.publisher()) {
if(ICE::ProcessSDPPacket(reader,(Peer&)*publication.publisher(),publication.publisher()->writer(),(Peer&)client,*_pDataWriter))
return;
}
if(_pDataTypeName == typeid(reader).name()) {
if(!_pDataWriter->writeMedia(Writer::DATA,0,reader.packet,*this))
init();
return;
}
shared_ptr<DataWriter> pWriter;
_pDataWriter->createWriter(pWriter);
if (!pWriter) {
if(!_pDataWriter->writeMedia(Writer::DATA,0,reader.packet,*this))
init();
return;
}
UInt32 offset = pWriter->packet.size();
reader.read(*pWriter);
reader.reset();
PacketReader packet(pWriter->packet.data(),pWriter->packet.size());
packet.next(offset);
if(!_pDataWriter->writeMedia(Writer::DATA,0,packet,*this))
init();
}
示例10: readName
void ClientSocket::readName(DataReader r){
int id = r.readInt();
char buf[33];
r.read(buf,32);
if(g.names.size()<=id)g.names.resize(id+20);
g.names[id] = buf;
std::cout<<id<<" is "<<buf<<"\n";
}
示例11: readItems
void ClientSocket::readItems(DataReader r)
{
int n=r.readInt();
Item it;
for(int i=0; i<n; ++i) {
r.read(&it, sizeof(it));
g.items_map.insert(it);
}
}
示例12: readDead
void ClientSocket::readDead(DataReader r){
int n = r.readInt();
for(int i=0;i<n;i++)
{
Unit u;
r.read(&u,sizeof(Unit));
u.shootTime = timef();
g.deadUnits.push_back(u);
}
}
示例13: read
void PartawareProvider::read(DataReader &reader) {
reader.read(this->m_cmc_rays_count);
reader.read(this->m_cmc_rays_theta);
reader.read(this->m_vsi_rays_count);
reader.read(this->m_geodestic_weight);
reader.read(this->m_angular_weight);
reader.read(this->m_vsi_weight);
reader.read(this->m_graph);
}
示例14: init
void Engine::init(DataReader& reader, const std::vector<Player*> players, const std::vector<GameObserver*>& observers)
{
// check that engine is not initialized yet
assert(!mPlayerIdCounter);
assert(mGeneratedIds.empty());
assert(mPlayers.empty());
assert(!mDeck);
assert(mGameObservers.empty());
// read players count
std::vector<const PlayerId*>::size_type playersCount;
reader.read(playersCount);
assert(players.size() == playersCount);
// add players
for (std::vector<Player*>::const_iterator it = players.begin(); it != players.end(); ++it) {
add(**it);
}
const Card defaultCard(SUIT_LAST, RANK_LAST);
// read each player cards
for (std::vector<const PlayerId*>::const_iterator it = mGeneratedIds.begin(); it != mGeneratedIds.end(); ++it) {
CardSet& playerCards = mPlayersCards[*it];
assert(playerCards.empty());
reader.read(playerCards, defaultCard);
mPlayers[*it]->cardsRestored(playerCards);
}
// read deck
Deck deck;
reader.read(deck, defaultCard);
Suit trumpSuit;
reader.read(trumpSuit);
deck.setTrumpSuit(trumpSuit);
setDeck(deck);
// read current player index
unsigned int currentPlayerindex;
reader.read(currentPlayerindex);
mCurrentPlayer = mGeneratedIds[currentPlayerindex];
// read current round index
reader.read(mRoundIndex);
bool roundRunning;
reader.read(roundRunning);
if (roundRunning) {
mCurrentRoundIndex = &mRoundIndex;
// read current round data
std::vector<const PlayerId*>::size_type attackersAmount;
reader.read(attackersAmount);
while (attackersAmount--) {
unsigned int attackerIndex;
reader.read(attackerIndex);
mAttackers.push_back(mGeneratedIds[attackerIndex]);
}
unsigned int defenderIndex;
reader.read(defenderIndex);
mDefender = mGeneratedIds[defenderIndex];
reader.read(mPassedCounter);
unsigned int currentRoundAttackerIndex;
reader.read(currentRoundAttackerIndex);
mCurrentRoundAttackerId = mGeneratedIds[currentRoundAttackerIndex];
std::vector<Card> attackCards;
reader.read(attackCards, defaultCard);
for (std::vector<Card>::iterator it = attackCards.begin(); it != attackCards.end(); ++it) {
mTableCards.addAttackCard(*it);
}
std::vector<Card> defendCards;
reader.read(defendCards, defaultCard);
for (std::vector<Card>::iterator it = defendCards.begin(); it != defendCards.end(); ++it) {
mTableCards.addDefendCard(*it);
}
reader.read(mMaxAttackCards);
reader.read(mDefendFailed);
mPickAttackCardFromTable = !mDefendFailed && attackCards.size() == defendCards.size() + 1;
}
// append observers
mGameObservers.insert(mGameObservers.end(), observers.begin(), observers.end());
std::map<const PlayerId*, unsigned int> playersCards;
for (PlayerIds::const_iterator it = mGeneratedIds.begin(); it != mGeneratedIds.end(); ++it) {
playersCards[*it] = mPlayersCards[*it].size();
}
std::for_each(mGameObservers.begin(), mGameObservers.end(), GameRestoredNotification(mGeneratedIds, playersCards, mDeck->size(), mDeck->trumpSuit(), mTableCards));
// initialize observers
unsigned int savedObservers;
reader.read(savedObservers);
assert(savedObservers == mGameObservers.size());
for (std::vector<GameObserver*>::iterator it = mGameObservers.begin(); it != mGameObservers.end(); ++it) {
unsigned int observerDataStart = reader.position();
(*it)->init(reader);
unsigned int actualObserverDataSize = reader.position() - observerDataStart;
unsigned int expectedObserverDataSize;
reader.read(expectedObserverDataSize);
assert(actualObserverDataSize == expectedObserverDataSize);
//.........这里部分代码省略.........
示例15: readBCount
void ClientSocket::readBCount(DataReader r)
{
r.read(g.bcnt, 8*4);
while(g.weapon && !g.bcnt[g.weapon]) --g.weapon;
}