本文整理汇总了C++中poco::Path::depth方法的典型用法代码示例。如果您正苦于以下问题:C++ Path::depth方法的具体用法?C++ Path::depth怎么用?C++ Path::depth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类poco::Path
的用法示例。
在下文中一共展示了Path::depth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getOFRelPath
string getOFRelPath(string from){
Poco::Path base(true);
base.parse(from);
Poco::Path path;
path.parse( getOFRoot() );
path.makeAbsolute();
cout << "getOFRelPath " << base.toString() << " " << path.toString() << endl;
string relPath;
if (path.toString() == base.toString()){
// do something.
}
int maxx = MAX(base.depth(), path.depth());
for (int i = 0; i <= maxx; i++){
bool bRunOut = false;
bool bChanged = false;
if (i <= base.depth() && i <= path.depth()){
if (base.directory(i) == path.directory(i)){
} else {
bChanged = true;
}
} else {
bRunOut = true;
}
if (bRunOut == true || bChanged == true){
for (int j = i; j <= base.depth(); j++){
relPath += "../";
}
for (int j = i; j <= path.depth(); j++){
relPath += path.directory(j) + "/";
}
break;
}
}
cout << relPath << " ---- " << endl;
return relPath;
}
示例2: updateServer
void ofxRemoteUIServer::updateServer(float dt){
timeCounter += dt;
broadcastTime += dt;
timeSinceLastReply += dt;
if(readyToSend){
if (timeCounter > updateInterval){
timeCounter = 0.0f;
//vector<string> changes = scanForUpdatedParamsAndSync(); //sends changed params to client
//cout << "ofxRemoteUIServer: sent " << ofToString(changes.size()) << " updates to client" << endl;
//sendUpdateForParamsInList(changes);
}
}
//let everyone know I exist and which is my port, every now and then
if(broadcastTime > OFXREMOTEUI_BORADCAST_INTERVAL){
if(doBroadcast){
broadcastTime = 0.0f;
if (computerName.size() == 0){
#ifdef OF_AVAILABLE
Poco::Environment e;
computerName = e.nodeName();
char pathbuf[2048];
uint32_t bufsize = sizeof(pathbuf);
#ifdef TARGET_OSX
_NSGetExecutablePath(pathbuf, &bufsize);
Poco::Path p = Poco::Path(pathbuf);
binaryName = p[p.depth()];
#endif
#ifdef TARGET_WIN32
GetModuleFileNameA( NULL, pathbuf, bufsize ); //no iea why, but GetModuleFileName() is not defined?
Poco::Path p = Poco::Path(pathbuf);
binaryName = p[p.depth()];
#endif
#endif
}
ofxOscMessage m;
m.addIntArg(port); //0
m.addStringArg(computerName); //1
m.addStringArg(binaryName); //2
broadcastSender.sendMessage(m);
}
}
while( oscReceiver.hasWaitingMessages() ){// check for waiting messages from client
ofxOscMessage m;
oscReceiver.getNextMessage(&m);
if (!readyToSend){ // if not connected, connect to our friend so we can talk back
connect(m.getRemoteIp(), port + 1);
}
DecodedMessage dm = decode(m);
RemoteUIServerCallBackArg cbArg; // to notify our "delegate"
cbArg.host = m.getRemoteIp();
switch (dm.action) {
case HELO_ACTION: //if client says hi, say hi back
sendHELLO();
if(callBack != NULL){
cbArg.action = CLIENT_CONNECTED;
callBack(cbArg);
}
if(verbose_) cout << "ofxRemoteUIServer: " << m.getRemoteIp() << " says HELLO!" << endl;
onScreenNotifications.addNotification("CONNECTED (" + cbArg.host + ")!");
break;
case REQUEST_ACTION:{ //send all params to client
if(verbose_) cout << "ofxRemoteUIServer: " << m.getRemoteIp() << " sends REQU!" << endl;
vector<string>paramsList = getAllParamNamesList();
syncAllParamsToPointers();
sendUpdateForParamsInList(paramsList);
sendREQU(true); //once all send, confirm to close the REQU
}
break;
case SEND_PARAM_ACTION:{ //client is sending us an updated val
if(verbose_) cout << "ofxRemoteUIServer: " << m.getRemoteIp() << " sends SEND!" << endl;
updateParamFromDecodedMessage(m, dm);
if(callBack != NULL){
cbArg.action = CLIENT_UPDATED_PARAM;
cbArg.paramName = dm.paramName;
cbArg.param = params[dm.paramName]; //copy the updated param to the callbakc arg
callBack(cbArg);
}
}
break;
case CIAO_ACTION:{
if(verbose_) cout << "ofxRemoteUIServer: " << m.getRemoteIp() << " says CIAO!" << endl;
sendCIAO();
onScreenNotifications.addNotification("DISCONNECTED (" + cbArg.host + ")!");
if(callBack != NULL){
cbArg.action = CLIENT_DISCONNECTED;
callBack(cbArg);
}
clearOscReceiverMsgQueue();
readyToSend = false;
//.........这里部分代码省略.........
示例3: main
int main(int argc, char *argv[]) {
std::string BuildVer(BUILD_VERSION);
cout<<"FastCraft Minecraft Server"<<"\n";
cout<<"Version "<<BUILD_VERSION<<(BuildVer.compare("") == 0 ? "" : "-")<<FC_VERSION<<" for Minecraft "<<FC_SUPPORTED_MINCRAFTVERSION<<"\n"<<std::endl;
Poco::Path pathRoot(argv[0]);
pathRoot.setFileName(""); //Remove filename
pathRoot.pushDirectory("Server");
Poco::File fileRootDirectory(pathRoot.toString());
if (!fileRootDirectory.exists()) {
try {
fileRootDirectory.createDirectories();
}catch(Poco::FileException& ex) {
cout<<"Unable to create server directory ("<<ex.message()<<")"<<std::endl;
}
}else{
if ((!fileRootDirectory.canRead()) || (!fileRootDirectory.canWrite())) {
cout<<"Unable to read or write FastCraft root directory"<<std::endl;
Thread::sleep(3000);
return 0;
}
}
std::vector<MinecraftServer*> vpServer(0);
std::vector<Poco::File> vFileList(0);
fileRootDirectory.list(vFileList);
if (vFileList.empty()) {
cout<<"No server configurations found!"<<std::endl;
Thread::sleep(3000);
return 0;
}
Poco::Data::SQLite::Connector::registerConnector(); //Startup sqlite engine
Constants::init(); //load constants
MinecraftServer* pServer;
Poco::Path pathTemp;
int x;
//Start all server
for (x=0;x<=vFileList.size()-1;x++) {
if (!vFileList[x].isDirectory()) {continue;} //Skip files
if(!pathTemp.tryParse(vFileList[x].path())) {
cout<<"Illegal path!"<<std::endl;
Thread::sleep(3000);
return 0;
}
try {
cout<<"Starting "<<pathTemp[pathTemp.depth()]<<"\n";
pathTemp.pushDirectory(pathTemp[pathTemp.depth()]);
pathTemp.setFileName("");
pServer = new MinecraftServer(pathTemp[pathTemp.depth()-1],pathTemp);
}catch(Poco::RuntimeException& ex) {
cout<<"Unable to start server ("<<ex.message()<<")"<<std::endl;
Thread::sleep(3000);
return 0;
}
vpServer.push_back(pServer);
pathTemp.clear();
}
cout<<"Loading done!\n";
bool fSomethingRuns = false;
while(1) {
Thread::sleep(1000);
//Check if there is at least one server that runs
fSomethingRuns=false;
for (x=0;x<=vpServer.size()-1;x++) {
if (vpServer[x]->isRunning()) {
fSomethingRuns=true;
break;
}
}
if (!fSomethingRuns) {break;}
}
Poco::Data::SQLite::Connector::unregisterConnector();
return 1;
}