Urbi SDK Remote for C++  2.7.5
umain.hh
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2009, 2010, 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 
00012 
00013 #ifndef URBI_UMAIN_HH
00014 # define URBI_UMAIN_HH
00015 
00016 # include <libport/cli.hh>
00017 # include <urbi/exit.hh>
00018 # include <urbi/uobject.hh>
00019 # include <urbi/urbi-root.hh>
00020 
00021 # ifdef STATIC_BUILD
00022 #  define UMAIN_URBIROOT_STATIC true
00023 # else
00024 #  define UMAIN_URBIROOT_STATIC false
00025 # endif
00026 
00027 # define UMAIN()                                                \
00028                                                                 \
00029   int                                                           \
00030   main(int argc, const char** argv)                             \
00031   {                                                             \
00032     UrbiRoot urbi_root(argv[0], UMAIN_URBIROOT_STATIC);         \
00033     std::vector<std::string> args(argv, argv + argc);           \
00034     return urbi_root.urbi_main(args, true, true);               \
00035   }                                                             \
00036                                                                 \
00037   int main_args(const libport::cli_args_type& args);            \
00038                                                                 \
00039   int                                                           \
00040   main_args(const libport::cli_args_type& args)                 \
00041   {                                                             \
00042     size_t argc = args.size();                                  \
00043     const char** argv = new const char*[argc];                  \
00044     for (unsigned i = 0; i < argc; ++i)                         \
00045       argv[i] = args[i].c_str();                                \
00046     int res = main(argc, argv);                                 \
00047     delete [] argv;                                             \
00048     return res;                                                 \
00049   }                                                             \
00050 
00051 extern "C"
00052 {
00054   URBI_SDK_API
00055   int urbi_main(int argc, const char* argv[], UrbiRoot& root,
00056                 bool block, bool errors);
00058   URBI_SDK_API
00059   int urbi_main_args(const libport::cli_args_type& args, UrbiRoot& root,
00060                      bool block, bool errors);
00061 }
00062 
00063 namespace urbi
00064 {
00065 
00072   URBI_SDK_API
00073   int
00074   main(const libport::cli_args_type& args, UrbiRoot& root,
00075        bool block = true, bool errors = false);
00076 
00079   URBI_SDK_API
00080   int
00081   main(int argc, const char *argv[], UrbiRoot& root,
00082        bool block = true, bool errors = false);
00083 
00084 
00097   URBI_SDK_API
00098   int
00099   initialize(const std::string& host, int port, size_t buflen,
00100              bool exitOnDisconnect, bool server = false,
00101              const std::vector<std::string>& files = std::vector<std::string>(),
00102              bool useSyncClient = true);
00103 }
00104 
00105 #endif /* !URBI_UMAIN_HH */