/** * 处理touch 事件 * \param touchType 点击类型 * \param touchPoint 点击的点 */ bool UICenterItem::onTouch(int touchType,const CCPoint &touchPoint) { if (disable) return false; if (!this->isVisible()) return false; switch(touchType) { case UICenterItem::TOUCH_DOWN: { if (checkIn(touchPoint)) { inTouch = true; nowTouchPoint = touchPoint; initWithSpriteFrame(downShow); } }break; case UICenterItem::TOUCH_END: { if (inTouch) { initWithSpriteFrame(upShow); if (checkIn(touchPoint)) onClick(); } inTouch = false; }break; } return inTouch; }
/** * 检查是否在区域里 */ bool UISuperBag::touchDown(float x,float y) { if (!this->isVisible()) return false; CCPoint pos = ccp(x,y); pos = this->convertToNodeSpace(pos); _touchIn = false; _nowTouchItemId = -1; nowTouchPoint = ccp(x,y); if (checkIn(pos.x,pos.y)) { if (!_editable) { _nowTouchItemId =getNowTouchBagIdByCursorPosition(nowTouchPoint); if (_nowTouchItemId < _items.size()) { UIItem * item = _items.at(_nowTouchItemId); if (!item || !item->canMove(_nowTouchItemId)) { _nowTouchItemId = -1; return false; } if (item) { item->setZOrder(2); } } } _touchIn = true; return true; } return false; }
string LyXVC::toggleReadOnly() { if (!vcs) return string(); if (!vcs->toggleReadOnlyEnabled()) return string(); switch (vcs->status()) { case VCS::UNLOCKED: LYXERR(Debug::LYXVC, "LyXVC: toggle to locked"); return checkOut(); case VCS::LOCKED: { LYXERR(Debug::LYXVC, "LyXVC: toggle to unlocked"); string log; if (checkIn(log) != VCSuccess) return string(); return log; } case VCS::NOLOCKING: Buffer * b = vcs->owner(); bool const newstate = !b->hasReadonlyFlag(); string result = "LyXVC: toggle to "; result += (newstate ? "readonly" : "readwrite"); LYXERR(Debug::LYXVC, result); b->setReadonly(newstate); return result; } return string(); }
void GameLayer::update( float dTime ) { //test code testCode(); setViewPort(this, m_Player->getPosition(), cocos2d::Point::ANCHOR_MIDDLE); m_BackGround->setPosition(-getPosition() + m_BackGround->getContentSize() / 2); m_RoomLayers[m_CurrentRoomNum]->update(dTime); m_Player->update(dTime); checkIn(); }
// Rename object and re-register with objectRegistry under new name void regIOobject::rename(const word& newName) { // Check out of objectRegistry checkOut(); IOobject::rename(newName); // Re-register object with objectRegistry checkIn(); }
void Immigrant::visit(std::shared_ptr<Courthouse> c) { courthouse = c; if (enter()) { checkIn(); sitDown(); swear(); getCertificate(); leave(); } }
int UISuperBag::getNowTouchBagIdByCursorPosition(const CCPoint& point) { CCPoint pos = this->convertToNodeSpace(point); if (checkIn(pos.x,pos.y)) { int dx = (pos.x - _viewx) / (_eachWidth); return dx; } return -1; }
bool UICenterItem::doTouchCanMove(int touchType,const CCPoint &touchPoint) { if (!this->isVisible()) return false; switch(touchType) { case UICenterItem::TOUCH_DOWN: { if (checkIn(touchPoint)) { inTouch = true; nowTouchPoint = touchPoint; initWithSpriteFrame(downShow); return true; } }break; case UICenterItem::TOUCH_MOVE: { if (inTouch && canMove) { CCPoint nowPoint = getPosition(); setPosition(ccp(nowPoint.x + touchPoint.x - nowTouchPoint.x, nowPoint.y + touchPoint.y - nowTouchPoint.y)); nowTouchPoint = touchPoint; return true; } }break; case UICenterItem::TOUCH_END: { if (inTouch) { initWithSpriteFrame(upShow); if (checkIn(touchPoint)) onClick(); } inTouch = false; }break; } return false; }
BOOL CLicenseMgr::CheckInLicense(const char *feature) { int res = checkIn(feature); if(!res) { return TRUE; } else { return FALSE; } }
/** * 检查是否在区域里 */ bool UIScrollView::touchDown(float x,float y) { if (!this->isVisible()) return false; CCPoint pos = ccp(x,y); nowTouchPoint = pos; startTouchPoint = pos; _touchIn = false; // pos = this->convertToNodeSpace(pos); if (!checkIn(pos.x,pos.y)) return false; if (child && child->touchDown(x,y)) { _touchIn = true; return true; } if (checkIn(pos.x,pos.y)) { _touchIn = true; return true; } return false; }
// Construct as copy, and transfering objectRegistry registration to copy // if registerCopy is true regIOobject::regIOobject(const regIOobject& rio, bool registerCopy) : IOobject(rio), registered_(false), ownedByRegistry_(false), lastModified_(rio.lastModified_), isPtr_(NULL) { if (registerCopy && rio.registered_) { const_cast<regIOobject&>(rio).checkOut(); checkIn(); } }
// Construct from IOobject regIOobject::regIOobject(const IOobject& io) : IOobject(io), registered_(false), ownedByRegistry_(false), lastModified_(0), isPtr_(NULL) { // Register with objectRegistry if requested if (registerObject()) { checkIn(); } }
// Construct as copy, and transfering objectRegistry registration to copy // if registerCopy is true Foam::regIOobject::regIOobject(const regIOobject& rio, bool registerCopy) : IOobject(rio), registered_(false), ownedByRegistry_(false), watchIndex_(-1), eventNo_(db().getEvent()), isPtr_(NULL) { if (registerCopy && rio.registered_) { const_cast<regIOobject&>(rio).checkOut(); checkIn(); } }
inline int HeterogeneousVolume::check(const Ray &inRay, float *intersectDist) const{ bool contactIsVol = inRay.contactObj && inRay.contactObj == this; if(!checkIn(inRay.origin, objID) && !contactIsVol){ return 1; } NoSelfCondition condition(scene, inRay); Scene::ObjSourceInfo info; float d = scene->intersect(inRay, info, &condition); if(!(d > 0)){ return 2; } if(intersectDist) *intersectDist = d; return 0; }
// Assign to IOobject void regIOobject::operator=(const IOobject& io) { if (isPtr_) { delete isPtr_; isPtr_ = NULL; } // Check out of objectRegistry checkOut(); IOobject::operator=(io); // Re-register object with objectRegistry checkIn(); }
int UICircleBag::getNowTouchBagIdByCursorPosition(const CCPoint& point) { CCPoint pos = this->convertToNodeSpace(point); // 检查是否在6个区域内 if (checkIn(pos.x,pos.y)) { for ( int i = 0; i < positions.size();i++) { CCRect rect = CCRectMake(positions[i].x,positions[i].y,_eachWidth,_eachHeight); if (rect.containsPoint(pos)) { return i; } } } return -1; }
inline float HeterogeneousVolume::lookUpDensity(const vec3f &worldPos) const{ if(!checkIn(worldPos, objID)) return 0; mat4f inverseTransform = inverse(this->transform); const vec3f localPos = vec3f(inverseTransform * vec4f(worldPos, 1)); if(localPos.x > mBBox.p1.x || localPos.x < mBBox.p0.x || localPos.y > mBBox.p1.y || localPos.y < mBBox.p0.y || localPos.z > mBBox.p1.z || localPos.z < mBBox.p0.z) { return 0; } float boundX = mBBox.p1.x - mBBox.p0.x, boundY = mBBox.p1.y - mBBox.p0.y, boundZ = mBBox.p1.z - mBBox.p0.z; float pToMinX = localPos.x - mBBox.p0.x, pToMinY = localPos.y - mBBox.p0.y, pToMinZ = localPos.z - mBBox.p0.z; int indexX = std::floor(mBBox.nx * pToMinX/boundX), indexY = std::floor(mBBox.ny * pToMinY/boundY), indexZ = std::floor(mBBox.nz * pToMinZ/boundZ); if(indexX < 0 || indexX >= mBBox.nx || indexY < 0 || indexY >= mBBox.ny || indexZ < 0 || indexZ >= mBBox.nz) { return 0; } float dx = mBBox.nx * pToMinX/boundX - indexX, dy = mBBox.ny * pToMinY/boundY - indexY, dz = mBBox.nz * pToMinZ/boundZ - indexZ; // Trilinearly interpolate density values to compute local density float sd00 = Lerp(dx, D(indexX, indexY, indexZ), D(indexX+1, indexY, indexZ)); float sd10 = Lerp(dx, D(indexX, indexY+1, indexZ), D(indexX+1, indexY+1, indexZ)); float sd01 = Lerp(dx, D(indexX, indexY, indexZ+1), D(indexX+1, indexY, indexZ+1)); float sd11 = Lerp(dx, D(indexX, indexY+1, indexZ+1), D(indexX+1, indexY+1, indexZ+1)); float sd0 = Lerp(dy, sd00, sd10); float sd1 = Lerp(dy, sd01, sd11); return Lerp(dz, sd0, sd1); return D(indexX, indexY, indexZ); }
Foam::regIOobject::regIOobject ( const IOobject& io, const regIOobject& rio ) : IOobject(io), registered_(false), ownedByRegistry_(false), watchIndex_(-1), eventNo_(db().getEvent()), isPtr_(NULL) { if (registerObject()) { checkIn(); } }
Foam::regIOobject::regIOobject ( const word& newName, const regIOobject& rio, bool registerCopy ) : IOobject(newName, rio.instance(), rio.local(), rio.db()), registered_(false), ownedByRegistry_(false), watchIndex_(-1), eventNo_(db().getEvent()), isPtr_(NULL) { if (registerCopy) { checkIn(); } }
void Foam::regIOobject::operator=(const IOobject& io) { if (isPtr_) { delete isPtr_; isPtr_ = nullptr; } // Check out of objectRegistry checkOut(); IOobject::operator=(io); if (registerObject()) { // Re-register object with objectRegistry checkIn(); } }
// Construct from IOobject Foam::regIOobject::regIOobject(const IOobject& io, const bool isTime) : IOobject(io), registered_(false), ownedByRegistry_(false), watchIndex_(-1), eventNo_ // Do not get event for top level Time database ( isTime ? 0 : db().getEvent() ), isPtr_(NULL) { // Register with objectRegistry if requested if (registerObject()) { checkIn(); } }
static bool executeExpr(char *jqBase, int32 jqPos, int32 op, JsonbValue *jb) { int32 type; int32 nextPos; check_stack_depth(); /* * read arg type */ jqPos = readJsQueryHeader(jqBase, jqPos, &type, &nextPos); Assert(nextPos == 0); Assert(type == jqiAny || type == jqiString || type == jqiNumeric || type == jqiNull || type == jqiBool || type == jqiArray); switch(op) { case jqiEqual: if (jb->type == jbvBinary && type == jqiArray) return checkArrayEquality(jqBase, jqPos, type, jb); return checkEquality(jqBase, jqPos, type, jb); case jqiIn: return checkIn(jqBase, jqPos, type, jb); case jqiOverlap: case jqiContains: case jqiContained: return executeArrayOp(jqBase, jqPos, type, op, jb); case jqiLess: case jqiGreater: case jqiLessOrEqual: case jqiGreaterOrEqual: return makeCompare(jqBase, jqPos, type, op, jb); default: elog(ERROR, "Unknown operation"); } return false; }
Foam::Callback<CallbackType>::Callback(CallbackRegistry<CallbackType>& cbr) : cbr_(cbr) { checkIn(); }
/** * 停止拖动 */ bool UISuperBag::touchEnd(float x,float y) { if (!this->isVisible()) return false; CCPoint pos = ccp(x,y); pos = this->convertToNodeSpace(pos); UIItem *srcItem = NULL; if (_nowTouchItemId < _items.size() && _nowTouchItemId >= 0) { srcItem = _items.at(_nowTouchItemId); oldTouchItemId = _nowTouchItemId; } if (!srcItem){ _nowTouchItemId = -1; _touchIn = false; return false; } if (srcItem) srcItem->setZOrder(0); UIItem *destItem = NULL; if (!_editable) { nowTouchPoint = ccp(x,y); if (checkIn(pos.x,pos.y)) { if (!_editable) { int nowTouchId = getNowTouchBagIdByCursorPosition(ccp(x,y)); if (nowTouchId >= _items.size()) { //_items.resize(_bagWidth * _bagHeight); } else { if (nowTouchId < _items.size() && nowTouchId >= 0) { destItem = _items.at(nowTouchId); } if (!destItem && nowTouchId < _items.size() && srcItem->canMove(nowTouchId)) { _items[nowTouchId] = srcItem; _items[_nowTouchItemId] = NULL; srcItem->bagId = nowTouchId; } else if (destItem && nowTouchId < _items.size()) { // 交换 if (destItem && srcItem && srcItem->canMove(destItem->bagId)) { _items[nowTouchId] = srcItem; _items[_nowTouchItemId] = destItem; destItem->bagId = _nowTouchItemId; srcItem->bagId = nowTouchId; } } else if (!destItem && (nowTouchId < 0 || nowTouchId >= _items.size())) { this->doEvent(UIBase::EVENT_DRAG_OUT,this); // 拖出包裹 } } } //return true; } else this->doEvent(UIBase::EVENT_DRAG_OUT,this); // 拖出包裹 } show(); if (srcItem == destItem) { this->doEvent(UIBase::EVENT_CLICK_DOWN,this); } _nowTouchItemId = -1; _touchIn = false; return true; }
int main( int argc, char * argv [] ) { boost::program_options::options_description optionsDescription( "options" ); optionsDescription.add_options() ("help", "produce help message") ("objectStoreRootPath", boost::program_options::value< std::string >()->default_value( "/var/lib/osmosis/objectstore" ), "Path where osmosis will store objects. relevant for 'server', 'purge', 'labellog' and 'leastrecentlyused' commands" ) ("serverTCPPort", boost::program_options::value< unsigned short >()->default_value( 1010 ), "the TCP port to bind to, if command is 'server'") ( "objectStores", boost::program_options::value< std::string >()->default_value( "127.0.0.1:1010" ), "the object store to act againt. May be a '+' seperated list for 'checkout' command" ) ( "MD5", "use MD5, not SHA1 for hash in 'checkin' operation" ) ( "putIfMissing", "when command is 'checkout' or 'transfer', this flag will cause any objects received not from the " "nearest object store to be put into all objects stores up to the one it was fetched from" ) ( "removeUnknownFiles", "for checkout: remove files from disk that are not in the dirlist being checked out" ) ( "myUIDandGIDcheckout", "for checkout: use my uid and gid" ) ( "ignore", boost::program_options::value< std::string >(), "for checkout: ignore the existance of all files in this ':' seperated list. " "if a directory was specified, ignored everything under it as well. specified paths " "must reside inside the checkout path" ) ( "transferDestination", boost::program_options::value< std::string >(), "destination object store to transfer the label into" ) ( "reportFile", boost::program_options::value< std::string >()->default_value( "" ), "periodically write report in JSON format into this file" ) ( "reportIntervalSeconds", boost::program_options::value< unsigned >()->default_value( 15 ), "period to report progress" ) ( "noChainTouch", "avoid touching fetched label in all object stores in chain (used for label bookeeping)" ) ( "keep", boost::program_options::value< std::string >()->default_value( "keepforever|bootstrap" ), "regular expression for labels to never erase. Only relevant under 'leastrecentlyused' command" ) ( "maximumDiskUsage", boost::program_options::value< std::string >(), "<number>M or <number>G for the amount of storage used for label objects before 'leastrecentlyused' starts erasing labels"); boost::program_options::options_description positionalDescription( "positionals" ); positionalDescription.add_options() ( "command", boost::program_options::value< std::string >() ) ( "arg1", boost::program_options::value< std::string >() ) ( "arg2", boost::program_options::value< std::string >() ); boost::program_options::positional_options_description positionalMapping; positionalMapping.add( "command", 1 ).add( "arg1", 1 ).add( "arg2", 1 ); boost::program_options::options_description allOptions; allOptions.add( optionsDescription ).add( positionalDescription ); boost::program_options::variables_map options; try { boost::program_options::store( boost::program_options::command_line_parser( argc, argv ). positional( positionalMapping ).options( allOptions ). run(), options ); boost::program_options::notify( options ); } catch ( boost::exception & e ) { TRACE_BOOST_EXCEPTION( e, "Unable to parse command line" ); usage( optionsDescription ); return 1; } if ( options.count( "help" ) ) { usage( optionsDescription ); return 1; } try { std::string command = options[ "command" ].as< std::string >(); if ( command == "server" ) { if ( options.count( "arg1" ) > 0 or options.count( "arg2" ) > 0 ) { TRACE_ERROR( "'workDir' or 'label' must not be present in command line" "if 'server' is specified as the command" ); usage( optionsDescription ); return 1; } server( options ); } else if ( command == "checkin" ) checkIn( options ); else if ( command == "checkout" ) checkOut( options ); else if ( command == "transfer" ) transfer( options ); else if ( command == "listlabels" ) listLabels( options ); else if ( command == "eraselabel" ) eraseLabel( options ); else if ( command == "purge" ) purge( options ); else if ( command == "renamelabel" ) renameLabel( options ); else if ( command == "labellog" ) dumpLabelLog( options ); else if ( command == "leastrecentlyused" ) leastRecentlyUsed( options ); else if ( command == "testhash" ) testHash( options ); else { TRACE_ERROR( "Unknown command '" << command << "'" ); usage( optionsDescription ); return 1; } } catch ( boost::exception & e ) { TRACE_BOOST_EXCEPTION( e, "Terminated on a boost exception" ); return 1; } catch ( Error & e ) { TRACE_ERROR( "Terminated on 'Error' exception: '" << e.what() << "' from " << e.backtrace() ); return 1; } catch ( std::exception & e ) { TRACE_ERROR( "Terminated on std::exception: '" << e.what() ); return 1; } catch ( ... ) { TRACE_ERROR( "Terminated on unknown exception" ); return 1; } return 0; }
void UFface::setRelation() { for(int i=1;i<NUM_FACE;i++) for(int j=0;j<i;j++) checkIn(i,j); }
Foam::Callback<CallbackType>::Callback(const Callback<CallbackType>& cb) : cbr_(cb.cbr_) { checkIn(); }