Urbi SDK Remote for C++  2.7.5
compatibility.hxx
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2009-2011, Gostai S.A.S.
00003  *
00004  * This software is provided "as is" without warranty of any kind,
00005  * either expressed or implied, including but not limited to the
00006  * implied warranties of fitness for a particular purpose.
00007  *
00008  * See the LICENSE file for more information.
00009  */
00010 
00011 #include <urbi/kernel-version.hh>
00012 #include <urbi/uabstractclient.hh>
00013 
00014 namespace urbi
00015 {
00016   namespace compatibility
00017   {
00018 
00019 
00020     /*----------------------.
00021     | evaluate_in_channel.  |
00022     `----------------------*/
00023 
00024     inline
00025     std::string
00026     evaluate_in_channel_open(const std::string& name, unsigned major)
00027     {
00028       if (major < 2)
00029         return name + " << ";
00030       else
00031         return SYNCLINE_WRAP("try { Channel.new(\"%s\") << {", name);
00032     }
00033 
00034     inline
00035     std::string
00036     evaluate_in_channel_close(const std::string& name, unsigned major)
00037     {
00038       if (major < 2)
00039         return ",";
00040       else
00041         return ("\n"
00042                 + SYNCLINE_WRAP(
00043                               "} }\n"
00044                               "catch (var e)\n"
00045                               "{\n"
00046                               "  lobby.send(\"!!! \" + e, \"%s\");\n"
00047                               "},", name));
00048     }
00049 
00050     /*-------.
00051     | emit.  |
00052     `-------*/
00053 
00054     inline
00055     std::string
00056     emit(const std::string& event, unsigned major)
00057     {
00058       return 2 <= major ? event + "!" : "emit " + event;
00059     }
00060 
00061 
00062     /*---------.
00063     | isvoid.  |
00064     `---------*/
00065 
00066     inline
00067     std::string
00068     isvoid(const std::string& exp, unsigned major)
00069     {
00070       return 2 <= major ?
00071         "(" + exp + ").isVoid" : "isvoid(" + exp + ")";
00072     }
00073 
00074 
00075     inline
00076     std::string
00077     stop(const std::string& tag, unsigned major)
00078     {
00079       return 2 <= major ?
00080         tag + ".stop" : "stop " + tag;
00081     }
00082   }
00083 }