本文整理汇总了C++中Leaf类的典型用法代码示例。如果您正苦于以下问题:C++ Leaf类的具体用法?C++ Leaf怎么用?C++ Leaf使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Leaf类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool
SoccerBase::GetActiveScene(const Leaf& base,
boost::shared_ptr<Scene>& active_scene)
{
static boost::shared_ptr<SceneServer> sceneServer;
if (sceneServer.get() == 0)
{
if (! GetSceneServer(base,sceneServer))
{
base.GetLog()->Error()
<< "(SoccerBase) ERROR: " << base.GetName()
<< ", could not get SceneServer\n";
return false;
}
}
active_scene = sceneServer->GetActiveScene();
if (active_scene.get() == 0)
{
base.GetLog()->Error()
<< "ERROR: (SoccerBase: " << base.GetName()
<< ", SceneServer reports no active scene\n";
return false;
}
return true;
}
示例2: checkTouchLeaf
void Level::checkTouchLeaf(Point point) {
if (this->hanged || this->done) {
return;
}
if (this->frog->getJumping()) {
return;
}
__Array* allLeavesKey = this->getLeaves()->allKeys();
for (int i = 0; i < allLeavesKey->count(); i++) {
__Integer* key = (__Integer*) allLeavesKey->getObjectAtIndex(i);
Leaf* leaf = (Leaf*) this->getLeaves()->objectForKey(key->getValue());
if (leaf->getDrowning()) {
continue;
}
RectBody* leafBody = (RectBody*) leaf->getBody();
if (CPointUtil::isPointInRectangle(point, leaf->getPosition(), leafBody->getWidth(), leafBody->getHeight())) {
ViewDirection willingDirection = this->checkJumpable(leaf);
if (willingDirection != VIEW_NONE) {
this->frog->setViewDirection(willingDirection);
this->frogJump(leaf);
}
break;
}
}
}
示例3: sqlite3_prepare_v2
bool
Db::insertLeafData(const Leaf& leaf, const Data& data)
{
if (leaf.getDataSeqNo() != m_nextLeafSeqNo)
return false;
sqlite3_stmt* statement;
sqlite3_prepare_v2(m_db,
"INSERT INTO leaves (dataSeqNo, dataName, signerSeqNo, timestamp, isCert, cert)\
VALUES (?, ?, ?, ?, 1, ?)",
-1, &statement, nullptr);
sqlite3_bind_int(statement, 1, leaf.getDataSeqNo());
sqlite3_bind_block(statement, 2, leaf.getDataName().wireEncode(), SQLITE_TRANSIENT);
sqlite3_bind_int(statement, 3, leaf.getSignerSeqNo());
sqlite3_bind_int(statement, 4, leaf.getTimestamp());
sqlite3_bind_block(statement, 5, data.wireEncode(), SQLITE_TRANSIENT);
int result = sqlite3_step(statement);
sqlite3_finalize(statement);
if (result == SQLITE_OK || result == SQLITE_DONE) {
m_nextLeafSeqNo++;
return true;
}
return false;
}
示例4: compute_node
void CipherText::compute_node(element_t& v, Node* node){//v amounts to s
if(node->getType() == LEAF){
Leaf* leaf = (Leaf*)node;
leaf->compute(&v, this->pub, this->p);
// printf("leaf: %d, %d, computed\n", leaf->getK(), leaf->getNum());
} else if (node->getType() == INTERNAL_NODE){
InternalNode* internalNode = (InternalNode*)node;
int num = internalNode->getNum();
int k = internalNode->getK();
Node** sons = internalNode->getSons();//??
// printf("internal Node: %d, %d\n", k, num);
element_t* ys = (element_t*)malloc(sizeof(element_t) * (num + 1));
element_init_Zr(ys[0], *(this->p));
element_set(ys[0], v); //set ys[0] to v
computePoints(ys, k, num); //compute other num point,
int i = 1;
for (i = 1; i <= num; i++){
compute_node(ys[i], sons[i - 1]);
}
}
}
示例5: throw
void GraphmlParser::parseXmlNodes(Element* xml, ProcessNetwork* processnetwork)
throw(InvalidArgumentException, ParseException, IOException,
RuntimeException) {
if (!xml) {
THROW_EXCEPTION(InvalidArgumentException, "\"xml\" must not be NULL");
}
if (!processnetwork) {
THROW_EXCEPTION(InvalidArgumentException, "\"processnetwork\" must not be NULL");
}
list<Element*> elements = getElementsByName(xml, "node");
list<Element*>::iterator it;
for (it = elements.begin(); it != elements.end(); ++it) {
logger_.logMessage(Logger::DEBUG, string("Analyzing line "
+ tools::toString((*it)->Row())
+ "..."));
Leaf* process = generateLeaf(*it);
try {
if (!processnetwork->addProcess(process)) {
THROW_EXCEPTION(ParseException, file_, (*it)->Row(),
(*it)->Column(),
string("Multiple processs with ID \"")
+ process->getId()->getString() + "\"");
}
} catch (bad_alloc&) {
THROW_EXCEPTION(OutOfMemoryException);
}
}
}
示例6: delete
void TabuSearch::adaptLeafs(LSMove* aMove) {
leafs.remove(aMove->out);
Leaf* toRemove = NULL;
for (list<Leaf*>::iterator aLeaf = leafs.begin(); aLeaf != leafs.end(); aLeaf++) {
Vertex* other = ((aMove->in)->getEdge())->otherVertex((aMove->in)->getVertex());
if ((*aLeaf)->getVertex() == other) {
toRemove = *aLeaf;
break;
}
}
if (toRemove != NULL) {
leafs.remove(toRemove);
delete(toRemove);
}
Vertex* ov = ((aMove->out)->getEdge())->otherVertex((aMove->out)->getVertex());
if (((*currentSol).incidentEdges(ov))->size() == 1) {
Edge* le = *(((*currentSol).incidentEdges(ov))->begin());
if ((*currentSol).isLeave(ov)) {
bool inserted = false;
list<Leaf*>::iterator aLeaf;
for (aLeaf = leafs.begin(); aLeaf != leafs.end(); aLeaf++) {
Edge* cle = (*aLeaf)->getEdge();
if (le->weight() >= cle->weight()) {
break;
inserted = true;
}
}
if (inserted == true) {
leafs.insert(aLeaf,new Leaf(le,ov));
}
else {
leafs.push_back(new Leaf(le,ov));
}
}
}
Leaf* newLeaf = (aMove->in)->copy();
Edge* le = newLeaf->getEdge();
bool inserted = false;
list<Leaf*>::iterator aLeaf;
for (aLeaf = leafs.begin(); aLeaf != leafs.end(); aLeaf++) {
Edge* cle = (*aLeaf)->getEdge();
if (le->weight() >= cle->weight()) {
break;
inserted = true;
}
}
if (inserted == true) {
leafs.insert(aLeaf,newLeaf);
}
else {
leafs.push_back(newLeaf);
}
}
示例7:
Leaf *find(StrItr begin, StrItr end) {
if(children.find(*begin) == children.end()) {
return NULL;
}
Leaf *leaf = children[*begin];
if(end-begin == 1) {
return leaf;
}
return leaf->find(begin+1, end);
};
示例8: DataEvent
void Level::updateLeaves(float dt) {
GameModel* gameModel = GameModel::getInstance();
for (auto iter = this->drowningLeaves->begin(); iter != this->drowningLeaves->end(); iter++) {
Leaf* drowningLeaf = (Leaf*) *iter;
if (drowningLeaf->getDrowning()) {
if (drowningLeaf->getCurrentDrownDuration() != -1) {
drowningLeaf->setCurrentDrownDuration(drowningLeaf->getCurrentDrownDuration() - dt);
if (drowningLeaf->getCurrentDrownDuration() < 0) {
drowningLeaf->setCurrentDrownDuration(-1);
DataEvent* dataEvent = new DataEvent();
dataEvent->setEventCode(EVT_LEAF_DROWN);
dataEvent->setArgumentReference(drowningLeaf);
gameModel->fireEvent(dataEvent);
this->leaves->removeObjectForKey(drowningLeaf->getPositionIndex());
this->drowningLeaves->eraseObject(drowningLeaf);
if (this->leaves->count() == 1) {
this->done = true;
}
break;
}
}
drowningLeaf->play(SPRITE_TYPE_MAIN, FRAME_LEAF_FALL);
}
}
}
示例9: ofEnableAlphaBlending
//--------------------------------------------------------------
void ofApp::setup(){
ofEnableAlphaBlending(); //allows you to use transparent colors
ofEnableSmoothing(); //make lines smoooooooooth...
numLeaves = (int)ofRandom(5,15);
for (int i = 0; i < numLeaves; i++){
Leaf tempLeaf;
tempLeaf.setup();
leaves.push_back(tempLeaf);
}
}
示例10: addTexture
void VolumeTextureAtlasBuilder::addTexture(const Leaf& leaf)
{
int x = m_itemCount % m_maxItemCountPerDimension.x;
int y = (m_itemCount / m_maxItemCountPerDimension.x) % m_maxItemCountPerDimension.y;
int z = m_itemCount / (m_maxItemCountPerDimension.x * m_maxItemCountPerDimension.y);
assert(leaf.getVoxelCountPerDimension() == m_itemTextureWidth);
leaf.toImageBuffer(*m_imageBuffer, glm::ivec3(x * m_itemTextureWidth, y * m_itemTextureWidth, z * m_itemTextureWidth));
++m_itemCount;
}
示例11: CompositeTest
///Composite 组合模式通过和 Decorator 模式有着类似的结构图,但是 Composite 模式旨在构造 类,而 Decorator 模式重在不生成子类即可给对象添加职责。Decorator 模式重在修饰,而 Composite 模式重在表示
void CompositeTest() {
Leaf* l = new Leaf();
l->Operation();
Composite* com = new Composite();
com->Add(l);
com->Operation();
NS_Composite::Component* ll = com->GetChild(0);
ll->Operation();
}
示例12: test_composite
void test_composite()
{
Leaf* l = new Leaf;
l->Operation();
ComponentComposite* com = new Composite;
com->Add(l);
com->Operation();
ComponentComposite* l1 = com->GetChild(0);
l1->Operation();
}
示例13: Leaf
void MainWindow::testComposition()
{
Leaf *pLeaf = new Leaf();
pLeaf->operation();
Composition *pComposion = new Composition();
pComposion->add(pLeaf);
pComposion->operation();
Component *pCom2 = pComposion->child(0);
pCom2->operation();
}
示例14: append
void append(QueryResult &result, StrItr begin, StrItr end) {
Leaf *leaf = NULL;
if(children.find(*begin) == children.end()) {
leaf = new Leaf();
children[*begin] = leaf;
} else {
leaf = children[*begin];
}
leaf->queryResults.insert(result);
if(end-begin > 1)
leaf->append(result, begin+1, end);
};
示例15: find
QuerySet find(vector<string> &tokens, vector<Boost> &boosts, int max = 20) {
QuerySet result;
vector<Leaf *> leafs;
for(vector<string>::iterator token = tokens.begin(); token != tokens.end(); token++) {
transform(token->begin(), token->end(), token->begin(), ::tolower);
Leaf *leaf = NULL;
leaf = root.find(token->begin(), token->end());
if(leaf == NULL)
return result;
leafs.push_back(leaf);
}
if(leafs.size() == 0) return result;
sort(leafs.begin(), leafs.end(), sortLeafs);
for(QuerySet::reverse_iterator queryResult = leafs[0]->queryResults.rbegin(); queryResult != leafs[0]->queryResults.rend(); queryResult++) {
bool inAll = true;
for(int i=1; i!=leafs.size(); i++) {
if(leafs[i]->queryResults.find(*queryResult) == leafs[i]->queryResults.end()) {
inAll = false;
break;
}
}
if(inAll)
result.insert(queryResult->boost(boosts));
if(boosts.size() == 0 && result.size() == max)
return result;
}
return result;
};