Revision: 8011
http://playerstage.svn.sourceforge.net/playerstage/?rev=8011&view=rev
Author: asadat
Date: 2009-07-13 23:38:04 +0000 (Mon, 13 Jul 2009)
Log Message:
-----------
added some code to generate the sample links at runtime
Modified Paths:
--------------
code/websim/src/req_sim.cc
code/websim/src/websim.hh
Modified: code/websim/src/req_sim.cc
===================================================================
--- code/websim/src/req_sim.cc 2009-07-13 23:37:43 UTC (rev 8010)
+++ code/websim/src/req_sim.cc 2009-07-13 23:38:04 UTC (rev 8011)
@@ -41,14 +41,7 @@
if(prop == "viz")
return HandleSimVisualizationRequest( action, format, kv, response );
- if(prop == "applet"){
-
-
-
- return true;
- }
-
response = "ERROR: Unknown property " + prop + " for sim. Candidates are:
clock factory greet tree.";
return false;
}
@@ -73,26 +66,38 @@
struct evkeyvalq* kv,
std::string& response)
{
+
+ std::vector<std::string> links;
+ GenerateSampleUrls(links);
+
+ //replacing 'HOST' by actual 'host:port' term
+ for(unsigned int j=0;j<links.size();j++){
+ unsigned int i=0;
+ i = links[j].find("HOST");
+ while(i!=std::string::npos){
+
+ links[j].replace(i, 4, hostportname);
+ i = links[j].find("HOST");
+ }
+ }
+
response = "<html><head><title>WebSim</title></head>"
"<body>"
"<h1>Welcome to " + IdentificationString() + "</h1>"
"<p>" + package + "-" + version + " HTTP interface to " +
IdentificationString() + "-" + VersionString() +
"</h1>"
- "<hr>"
- "<p><a href=\"http://playerstage.org/index.php?src=websim\">WebSim</a>"
+ "<hr>";
+
+ for(unsigned int k=0;k<links.size();k++)
+ response += links[k];
+
+ response +="<hr>"
+ "<p><a href=\"http://playerstage.org/index.php?src=websim\">WebSim</a>"
" is part of the <a href=\"http://playerstage.org\">Player Project</a>"
"</body></html>";
-// // replacing 'HOST' by actual 'host:port' term
-// unsigned int i=0;
-// i = response.find("HOST");
-// while(i!=std::string::npos){
-// response.replace(i, 4, hostportname);
-// i = response.find("HOST");
-// }
-
return true;
}
@@ -265,3 +270,37 @@
response = "ERROR: Unknown action " + action + " for sim/clock. Candidates
are: get (default) start stop.";
return false;
}
+
+void WebSim::GenerateSampleUrls(std::vector<std::string> &list){
+
+ std::vector<std::string> interfaces;
+ std::vector<std::string> temp;
+
+
+ GetModelChildren("",temp);
+ while(temp.size()>0 && interfaces.size() < 6){
+
+ std::string m = temp.at(0);
+ temp.erase(temp.begin());
+
+ int size = temp.size();
+ GetModelChildren(m, temp);
+ if(temp.size()==size){
+
+ interfaces.push_back(m);
+
+ }
+
+
+ }
+
+ for(unsigned int i=0;i<interfaces.size();i++){
+ if(interfaces[i].find("laser")!=std::string::npos ||
interfaces[i].find("fiducial")!=std::string::npos ||
+ interfaces[i].find("irarray")!=std::string::npos)
+ list.push_back("<a href=http://HOST/"+interfaces[i]+"/data/get
> http://HOST/"+interfaces[i]+"/data/get</a> <br>");
+
+ }
+
+}
+
+
Modified: code/websim/src/websim.hh
===================================================================
--- code/websim/src/websim.hh 2009-07-13 23:37:43 UTC (rev 8010)
+++ code/websim/src/websim.hh 2009-07-13 23:38:04 UTC (rev 8011)
@@ -224,6 +224,7 @@
Acceleration& a );
protected:
+ void GenerateSampleUrls(std::vector<std::string> &list);
void StringSplit(const std::string &s,
std::vector<std::string> &t,
const std::string &d);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit