本文整理汇总了C++中Ptr::AS方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::AS方法的具体用法?C++ Ptr::AS怎么用?C++ Ptr::AS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ptr
的用法示例。
在下文中一共展示了Ptr::AS方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deserialize
void ManifestoElement::deserialize(PPtr<ObjectToken> headToken) {
headToken->validateClass(MANIFESTO);
Ptr<Token> token = headToken->next();
while(token->is(Token::OBJECT)) {
PPtr<ObjectToken> obj = token.AS(ObjectToken);
if(obj->checkClass(LoadElement::LOAD)) {
Ptr<LoadElement> e = new LoadElement();
e->deserialize(obj);
_loadElements->push(e);
_rt.loadClass(e->getClassName());
} else if(obj->checkClass(RunElement::RUN)) {
Ptr<RunElement> e = new RunElement();
e->deserialize(obj);
_runElements->push(e);
} else if(obj->checkClass(MessageElement::MESSAGE)) {
Ptr<MessageElement> e = new MessageElement(_rt);
e->deserialize(obj);
_messageElements->push(e);
} else if(obj->checkClass(PeerElement::CONNECT)) {
Ptr<PeerElement> e = new PeerElement();
e->deserialize(obj);
_peerElements->push(e);
} else {
obj->throwInvlaidClass();
}
token = token->next();
}
token->validateType(Token::END_OBJECT);
}
示例2: computeLoop
void CellAutomataAgent::computeLoop() {
_readFromLayer1 = true;
PPtr<KGridBasic> readLayer = _layer1;
PPtr<KGridBasic> writeLayer = _layer2;
Ptr<KGridWindow> displayWindow
= new KGridWindow(_layer1.AS(KGrid), _computeRange);
int phase = 1;
ProximityIterator j(1);
while(!_stopFlag) {
displayWindow->setSource(readLayer.AS(KGrid));
_pPixmap.tput(phase, displayWindow.AS(KGrid));
exchangeBorders(phase);
System::sleep(_delay);
evaluate(readLayer, writeLayer, phase);
_readFromLayer1 = !_readFromLayer1;
if(_readFromLayer1) {
readLayer = _layer1;
writeLayer = _layer2;
} else {
readLayer = _layer2;
writeLayer = _layer1;
}
phase++;
}
}
示例3: deserialize
void KOctet::deserialize(PPtr<ObjectToken> headToken) {
headToken->validateClass("KOctet");
Ptr<Token> token = headToken->next();
token->validateType(AttributeToken::TYPE);
Ptr<AttributeToken> attrib = token.AS(AttributeToken);
set(Int::parse(attrib->validateName("value")->getValue()));
token = token->next();
token->validateType(EndObjectToken::TYPE);
}
示例4: makeAndDistributePartitionTable
void CellAutomataAgent::makeAndDistributePartitionTable() {
Range indexRange = _pDisplayInfo.getGlobalIndexRange();
Tuple nDivs = indexRange.getSize();
Ptr< Array<int> > xDivs = divideScalarRange(0, _globalSize.at(0), nDivs.at(0));
Ptr< Array<int> > yDivs = divideScalarRange(0, _globalSize.at(1), nDivs.at(1));
PPtr< ManagedArray<DisplayInfoProtocol::NodeInfo> > nodes
= _pDisplayInfo.getRemoteInfo();
Ptr< ManagedArray<Partition> > partitions = new ManagedArray<Partition>();
for(int i = nodes->getSize() - 1; i >= 0; i--) {
partitions->push(nodeToPartition(xDivs, yDivs, nodes->at(i)));
}
_local = nodeToPartition(xDivs, yDivs, _pDisplayInfo.getLocalInfo());
partitions->push(_local);
ALOG << "Partition Map: " << *partitions << EL;
Tuple1D gridSize(partitions->getSize());
Ptr<KGridBasic> grid = new KGridBasic(partition_map_t(), gridSize);
Ptr<KRecord> gridRecord = new KRecord(grid.AS(KGrid));
for(RangeIterator i(gridSize); i.hasMore(); i.next()) {
partitions->at(i.at(0))->toKRecord(grid->at(i, gridRecord));
}
send(R_MATE, OP_PARTITION, grid.AS(KValue));
for(int i = partitions->getSize() - 1; i >= 0; i--) {
if(partitions->at(i)->rect.isAdjecentTo(_local->rect)) {
_neighbours->push(partitions->at(i));
}
}
_computeThread->start();
}
示例5: KEnumerationType
SPtr<KRecordType> CellAutomataAgent::start_t() {
if(START_T.isNull()) {
Ptr<KEnumerationType> problemType = new KEnumerationType("knorba.demo.cell-automata.Problem");
problemType->addMember(LIFE, "life");
problemType->addMember(BRAIN, "brain");
problemType->addMember(ANT, "ant");
START_T = new KRecordType("knorba.demo.cell-automata.Start");
START_T->addField("problem", problemType.AS(KType))
->addField("width", KType::INTEGER)
->addField("height", KType::INTEGER);
}
return START_T;
}
示例6: insertIntoInsertions
void StringBuilder::insertIntoInsertions(
Ptr<StringBuilder::Insertion> insertion)
{
int insertionIndex = _insertions->getSize();
kf_int64_t pos = insertion.AS(InsertionHead)->getPos();
for(int i = insertionIndex - 1; i >= 0; i--) {
if(pos < _insertions->at(i).AS(InsertionHead)->getPos())
insertionIndex = i;
else
break;
}
_insertions->insert(insertionIndex, insertion);
}
示例7: processInput
void ChatAgent::processInput(PPtr<KString> input) {
if(_nickName.empty()) {
_nickName = input->toUtf8String();
_pConsole.print("You shall be known as \"" + _nickName + "\".");
_pConsole.print("Type anything to send. Enter \"quit\" to finish.");
} else if(input->equals("quit")) {
_pConsole.print("Bye!");
quit();
} else {
Ptr<KRecord> message = new KRecord(message_t());
message->getString(MESSAGE_T_SENDER)->set(_nickName);
message->getString(MESSAGE_T_CONTENT)->set(input.AS(KValue));
sendToAll(OP_MESSAGE, message.AS(KValue));
}
}
示例8: readFromXmlStream
void StreamDeserializer::readFromXmlStream(PPtr<InputStream> stream) {
Ptr<XmlObjectStreamReader> reader = new XmlObjectStreamReader(stream);
Ptr<Token> headToken = reader->next();
headToken->validateType(Token::OBJECT);
deserialize(headToken.AS(ObjectToken));
}