Changeset 41:19321fe993cb in rrlib_util


Ignore:
Timestamp:
15.01.2012 04:15:07 (8 years ago)
Author:
Tobias Föhst <foehst@…>
Branch:
default
Phase:
public
Message:

Fixed namespace usage

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • sFileIOUtils.cpp

    r40 r41  
    5151#include "rrlib/logging/messages.h" 
    5252 
     53//---------------------------------------------------------------------- 
     54// Debug 
     55//---------------------------------------------------------------------- 
     56#include <cassert> 
     57 
     58//---------------------------------------------------------------------- 
     59// Namespace usage 
     60//---------------------------------------------------------------------- 
    5361using namespace std; 
    54 using namespace rrlib::util; 
    55  
    56 //---------------------------------------------------------------------- 
    57 // Debug 
    58 //---------------------------------------------------------------------- 
    59 #include <cassert> 
     62 
     63//---------------------------------------------------------------------- 
     64// Namespace declaration 
     65//---------------------------------------------------------------------- 
     66namespace rrlib 
     67{ 
     68namespace util 
     69{ 
    6070 
    6171//---------------------------------------------------------------------- 
     
    121131  if (system(sys_call.str().c_str()) == -1) 
    122132  { 
    123     RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "sFileIOUtils>> Error creating dir: '%s'\n", path.c_str()); 
     133    RRLIB_LOG_PRINTF(logging::eLL_USER, "sFileIOUtils>> Error creating dir: '%s'\n", path.c_str()); 
    124134//     std::stringstream error_msg; 
    125135//     error_msg << "sFileIOUtils>> Error creating Dir:\n" 
     
    130140  else 
    131141  { 
    132 //     RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "sFileIOUtils>> Directory: '%s' successfully created.\n", path.c_str()); 
     142//     RRLIB_LOG_PRINTF(logging::eLL_USER, "sFileIOUtils>> Directory: '%s' successfully created.\n", path.c_str()); 
    133143    return true; 
    134144  } 
     
    144154  if (fgets(buf, sizeof(buf), pipe) == 0) 
    145155  { 
    146     RRLIB_LOG_PRINTF(rrlib::logging::eLL_ERROR, "sFileIOUtils::CreateTempfile() >> Error creating temp file!\n"); 
     156    RRLIB_LOG_PRINTF(logging::eLL_ERROR, "sFileIOUtils::CreateTempfile() >> Error creating temp file!\n"); 
    147157    exit(EXIT_FAILURE); 
    148158  } 
     
    172182  if (system(cmd.str().c_str()) != 0) 
    173183  { 
    174     RRLIB_LOG_PRINTF(rrlib::logging::eLL_ERROR, "sFileIOUtils>> Execution of command '%s' failed!\n", cmd.str().c_str()); 
     184    RRLIB_LOG_PRINTF(logging::eLL_ERROR, "sFileIOUtils>> Execution of command '%s' failed!\n", cmd.str().c_str()); 
    175185    exit(EXIT_FAILURE); 
    176186  } 
     
    187197  if (system(cmd.str().c_str()) != 0) 
    188198  { 
    189     RRLIB_LOG_PRINTF(rrlib::logging::eLL_ERROR, "sFileIOUtils>> Execution of command '%s' failed!\n", cmd.str().c_str()); 
     199    RRLIB_LOG_PRINTF(logging::eLL_ERROR, "sFileIOUtils>> Execution of command '%s' failed!\n", cmd.str().c_str()); 
    190200    exit(EXIT_FAILURE); 
    191201  } 
     
    228238      error_msg = "Unknown error"; 
    229239    } 
    230     RRLIB_LOG_PRINTF(rrlib::logging::eLL_ERROR, "sFileIOUtils::%s >> Could not expand '%s': %s!\n", __FUNCTION__, file_name.c_str(), error_msg); 
     240    RRLIB_LOG_PRINTF(logging::eLL_ERROR, "sFileIOUtils::%s >> Could not expand '%s': %s!\n", __FUNCTION__, file_name.c_str(), error_msg); 
    231241    return false; 
    232242  } 
    233243 
    234244  std::stringstream stream; 
    235   stream << rrlib::util::Join(expansion.we_wordv + expansion.we_offs, expansion.we_wordv + expansion.we_offs + expansion.we_wordc, " "); 
     245  stream << util::Join(expansion.we_wordv + expansion.we_offs, expansion.we_wordv + expansion.we_offs + expansion.we_wordc, " "); 
    236246  wordfree(&expansion); 
    237247 
     
    285295std::string sFileIOUtils::GetHostName(bool fqdn) 
    286296{ 
    287   //RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "sFileIOUtils::GetHostName() >>> started\n"); 
     297  //RRLIB_LOG_PRINTF(logging::eLL_USER, "sFileIOUtils::GetHostName() >>> started\n"); 
    288298  std::string cmd = fqdn ? "hostname -f" : "hostname"; 
    289299  FILE * pipe = popen(cmd.c_str(), "r"); 
     
    291301  if (fgets(buf, sizeof(buf), pipe) == 0) 
    292302  { 
    293     RRLIB_LOG_PRINTF(rrlib::logging::eLL_ERROR, "sFileIOUtils::GetHostName(bool fqdn) >> Error querying host name!\n"); 
     303    RRLIB_LOG_PRINTF(logging::eLL_ERROR, "sFileIOUtils::GetHostName(bool fqdn) >> Error querying host name!\n"); 
    294304    exit(EXIT_FAILURE); 
    295305  } 
     
    298308  sStringUtils::TrimWhitespace(name); 
    299309  //boost::trim(name); 
    300   //RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "sFileIOUtils::GetHostName() >>> finished with name <%s>\n", name.c_str()); 
     310  //RRLIB_LOG_PRINTF(logging::eLL_USER, "sFileIOUtils::GetHostName() >>> finished with name <%s>\n", name.c_str()); 
    301311  return name; 
    302312} // GetHostName() 
     
    313323  { 
    314324    address = * ((struct in_addr *) host_ent->h_addr_list[ 0 ]); 
    315     RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "ip address of host <%s> = <%s>\n", name.c_str(), inet_ntoa(address)); 
    316   } 
    317   else 
    318   { 
    319     RRLIB_LOG_PRINTF(rrlib::logging::eLL_ERROR, "sFileIOUtils::GetIpAddressOfHost() >>> could not get ip address of host <%s>\n", name.c_str()); 
     325    RRLIB_LOG_PRINTF(logging::eLL_USER, "ip address of host <%s> = <%s>\n", name.c_str(), inet_ntoa(address)); 
     326  } 
     327  else 
     328  { 
     329    RRLIB_LOG_PRINTF(logging::eLL_ERROR, "sFileIOUtils::GetIpAddressOfHost() >>> could not get ip address of host <%s>\n", name.c_str()); 
    320330  } 
    321331  return address; 
     
    328338struct in_addr sFileIOUtils::HostToIpViaNslookup(const std::string & name) 
    329339{ 
    330   RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "sFileIOUtils::HostToIpViaNslookup() >>> started with host <%s>\n", name.c_str()); 
     340  RRLIB_LOG_PRINTF(logging::eLL_USER, "sFileIOUtils::HostToIpViaNslookup() >>> started with host <%s>\n", name.c_str()); 
    331341  struct in_addr address; 
    332342  address.s_addr = 0; 
     
    334344  std::stringstream command; 
    335345  command << "nslookup \"" << name << "\""; 
    336   RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "command = <%s>\n", command.str().c_str()); 
     346  RRLIB_LOG_PRINTF(logging::eLL_USER, "command = <%s>\n", command.str().c_str()); 
    337347  FILE * pipe = popen(command.str().c_str(), "r"); 
    338348  if (!pipe) 
     
    348358  } 
    349359  pclose(pipe); 
    350   RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "sFileIOUtils::HostToIpViaNslookup() >>> host = <%s> , result = <%s> \n", name.c_str(), result.str().c_str()); 
     360  RRLIB_LOG_PRINTF(logging::eLL_USER, "sFileIOUtils::HostToIpViaNslookup() >>> host = <%s> , result = <%s> \n", name.c_str(), result.str().c_str()); 
    351361 
    352362  std::string result_str(result.str()); 
     
    355365  if (pos == std::string::npos) 
    356366  { 
    357     RRLIB_LOG_PRINTF(rrlib::logging::eLL_ERROR, "Could not find token <%s> in nslookup result ... returning <%s> \n", search_token.c_str(), inet_ntoa(address)); 
     367    RRLIB_LOG_PRINTF(logging::eLL_ERROR, "Could not find token <%s> in nslookup result ... returning <%s> \n", search_token.c_str(), inet_ntoa(address)); 
    358368    return address; 
    359369  } 
    360370  result_str.erase(0, pos + search_token.length()); 
    361   RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "pos = %zd\n", pos); 
     371  RRLIB_LOG_PRINTF(logging::eLL_USER, "pos = %zd\n", pos); 
    362372 
    363373  search_token = "Address:"; 
     
    365375  if (pos == std::string::npos) 
    366376  { 
    367     RRLIB_LOG_PRINTF(rrlib::logging::eLL_ERROR, "Could not find token <%s> in nslookup result ... returning <%s> \n", search_token.c_str(), inet_ntoa(address)); 
     377    RRLIB_LOG_PRINTF(logging::eLL_ERROR, "Could not find token <%s> in nslookup result ... returning <%s> \n", search_token.c_str(), inet_ntoa(address)); 
    368378    return address; 
    369379  } 
    370   RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "pos = %zd\n", pos); 
     380  RRLIB_LOG_PRINTF(logging::eLL_USER, "pos = %zd\n", pos); 
    371381 
    372382  std::string found_name(result_str.substr(0, pos)); 
     
    377387  //boost::trim(ip); 
    378388 
    379   RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "found_name <%s> , name <%s> \n", found_name.c_str(), name.c_str()); 
     389  RRLIB_LOG_PRINTF(logging::eLL_USER, "found_name <%s> , name <%s> \n", found_name.c_str(), name.c_str()); 
    380390 
    381391  if (found_name != name) 
    382392  { 
    383     RRLIB_LOG_PRINTF(rrlib::logging::eLL_ERROR, "nslookup failed .... returning <%s> \n", inet_ntoa(address)); 
     393    RRLIB_LOG_PRINTF(logging::eLL_ERROR, "nslookup failed .... returning <%s> \n", inet_ntoa(address)); 
    384394    return address; 
    385395  } 
    386   RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "found_name <%s> , ip <%s> \n", found_name.c_str(), ip.c_str()); 
     396  RRLIB_LOG_PRINTF(logging::eLL_USER, "found_name <%s> , ip <%s> \n", found_name.c_str(), ip.c_str()); 
    387397 
    388398  inet_aton(ip.c_str(), &address); 
     
    398408struct in_addr sFileIOUtils::HostToIpViaHost(const std::string & name) 
    399409{ 
    400   RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "sFileIOUtils::HostToIpViaHost() >>> started with host <%s>\n", name.c_str()); 
     410  RRLIB_LOG_PRINTF(logging::eLL_USER, "sFileIOUtils::HostToIpViaHost() >>> started with host <%s>\n", name.c_str()); 
    401411  struct in_addr address; 
    402412  address.s_addr = 0; 
     
    404414  std::stringstream command; 
    405415  command << "host -t A \"" << name << "\""; 
    406   RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "command = <%s>\n", command.str().c_str()); 
     416  RRLIB_LOG_PRINTF(logging::eLL_USER, "command = <%s>\n", command.str().c_str()); 
    407417  FILE * pipe = popen(command.str().c_str(), "r"); 
    408418  if (!pipe) 
     
    418428  } 
    419429  pclose(pipe); 
    420   RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "sFileIOUtils::HostToIpViaHost() >>> host = <%s> , result = <%s> \n", name.c_str(), result.str().c_str()); 
     430  RRLIB_LOG_PRINTF(logging::eLL_USER, "sFileIOUtils::HostToIpViaHost() >>> host = <%s> , result = <%s> \n", name.c_str(), result.str().c_str()); 
    421431 
    422432  std::string result_str(result.str()); 
     
    425435 
    426436  for_each(tokens.begin(), tokens.end(), sStringUtils::Trim<std::string>()); 
    427   RRLIB_LOG_PRINTF(rrlib::logging::eLL_DEBUG_VERBOSE_1, "sFileIOUtils::HostToIpViaHost() >>> got %d tokens:\n", tokens.size()); 
    428   RRLIB_LOG_PRINT(rrlib::logging::eLL_DEBUG_VERBOSE_1, Join(tokens, "\n")); 
     437  RRLIB_LOG_PRINTF(logging::eLL_DEBUG_VERBOSE_1, "sFileIOUtils::HostToIpViaHost() >>> got %d tokens:\n", tokens.size()); 
     438  RRLIB_LOG_PRINT(logging::eLL_DEBUG_VERBOSE_1, Join(tokens, "\n")); 
    429439 
    430440  assert(tokens.size() == 4); 
    431   RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "found_name <%s> , ip <%s> \n", tokens[0].c_str(), tokens[3].c_str()); 
     441  RRLIB_LOG_PRINTF(logging::eLL_USER, "found_name <%s> , ip <%s> \n", tokens[0].c_str(), tokens[3].c_str()); 
    432442 
    433443  inet_aton(tokens[3].c_str(), &address); 
     
    440450struct in_addr sFileIOUtils::HostToIpViaHostsFile(const std::string & name) 
    441451{ 
    442   RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "sFileIOUtils::HostToIpViaHostsFile() >>> started with host <%s>\n", name.c_str()); 
     452  RRLIB_LOG_PRINTF(logging::eLL_USER, "sFileIOUtils::HostToIpViaHostsFile() >>> started with host <%s>\n", name.c_str()); 
    443453  struct in_addr address; 
    444454  address.s_addr = 0; 
     
    466476          { 
    467477            ip_address = *iter; 
    468             RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "sFileIOUtils::HostToIpViaHostsFile() >>> got ip <%s> of host <%s> from hosts file\n", ip_address.c_str(), name.c_str()); 
     478            RRLIB_LOG_PRINTF(logging::eLL_USER, "sFileIOUtils::HostToIpViaHostsFile() >>> got ip <%s> of host <%s> from hosts file\n", ip_address.c_str(), name.c_str()); 
    469479            found = true; 
    470480            break; 
     
    484494struct in_addr sFileIOUtils::HostToIp(const std::string & name) 
    485495{ 
    486   RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "sFileIOUtils::HostToIp() >>> started with host <%s>\n", name.c_str()); 
     496  RRLIB_LOG_PRINTF(logging::eLL_USER, "sFileIOUtils::HostToIp() >>> started with host <%s>\n", name.c_str()); 
    487497 
    488498  struct in_addr address; 
     
    491501  if ((address = sFileIOUtils::HostToIpViaHostsFile(name)).s_addr != 0) 
    492502  { 
    493     RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "sFileIOUtils::HostToIp() >>> got ip <%s> of host <%s> from hosts_file\n", inet_ntoa(address), name.c_str()); 
     503    RRLIB_LOG_PRINTF(logging::eLL_USER, "sFileIOUtils::HostToIp() >>> got ip <%s> of host <%s> from hosts_file\n", inet_ntoa(address), name.c_str()); 
    494504  } 
    495505  else if ((address = sFileIOUtils::HostToIpViaHost(name)).s_addr != 0) 
    496506  { 
    497     RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "sFileIOUtils::HostToIp() >>> got ip <%s> of host <%s> via <host -t A>\n", inet_ntoa(address), name.c_str()); 
     507    RRLIB_LOG_PRINTF(logging::eLL_USER, "sFileIOUtils::HostToIp() >>> got ip <%s> of host <%s> via <host -t A>\n", inet_ntoa(address), name.c_str()); 
    498508  } 
    499509  else if ((address = sFileIOUtils::HostToIpViaNslookup(name)).s_addr != 0) 
    500510  { 
    501     RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "sFileIOUtils::HostToIp() >>> got ip <%s> of host <%s> via <nslookup>\n", inet_ntoa(address), name.c_str()); 
    502   } 
    503   else 
    504   { 
    505     RRLIB_LOG_PRINTF(rrlib::logging::eLL_ERROR, "sFileIOUtils::HostToIp() >>> could not get ip of host <%s>\n", name.c_str()); 
     511    RRLIB_LOG_PRINTF(logging::eLL_USER, "sFileIOUtils::HostToIp() >>> got ip <%s> of host <%s> via <nslookup>\n", inet_ntoa(address), name.c_str()); 
     512  } 
     513  else 
     514  { 
     515    RRLIB_LOG_PRINTF(logging::eLL_ERROR, "sFileIOUtils::HostToIp() >>> could not get ip of host <%s>\n", name.c_str()); 
    506516  } 
    507517 
     
    531541  << target_directory; 
    532542 
    533   RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "sFileIOUtils::RSyncFile() >>> executing <%s> ...\n", rsync_command.str().c_str()); 
     543  RRLIB_LOG_PRINTF(logging::eLL_USER, "sFileIOUtils::RSyncFile() >>> executing <%s> ...\n", rsync_command.str().c_str()); 
    534544  int ret = system(rsync_command.str().c_str()); 
    535   RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "sFileIOUtils::RSyncFile() >>> ... done.\n"); 
    536  
    537   RRLIB_LOG_PRINTF(rrlib::logging::eLL_ERROR, "sFileIOUtils::RSyncFile() >>> finished with result %d\n", ret); 
     545  RRLIB_LOG_PRINTF(logging::eLL_USER, "sFileIOUtils::RSyncFile() >>> ... done.\n"); 
     546 
     547  RRLIB_LOG_PRINTF(logging::eLL_ERROR, "sFileIOUtils::RSyncFile() >>> finished with result %d\n", ret); 
    538548  return ret; 
    539549} // RSyncFile() 
     
    566576  << target_directory; 
    567577 
    568   RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "sFileIOUtils::RSyncFiles() >>> executing <%s> ...\n", rsync_command.str().c_str()); 
     578  RRLIB_LOG_PRINTF(logging::eLL_USER, "sFileIOUtils::RSyncFiles() >>> executing <%s> ...\n", rsync_command.str().c_str()); 
    569579  int ret = system(rsync_command.str().c_str()); 
    570   RRLIB_LOG_PRINTF(rrlib::logging::eLL_USER, "sFileIOUtils::RSyncFiles() >>> ... done.\n"); 
    571  
    572   RRLIB_LOG_PRINTF(rrlib::logging::eLL_ERROR, "sFileIOUtils::RSyncFiles() >>> finished with result %d\n", ret); 
     580  RRLIB_LOG_PRINTF(logging::eLL_USER, "sFileIOUtils::RSyncFiles() >>> ... done.\n"); 
     581 
     582  RRLIB_LOG_PRINTF(logging::eLL_ERROR, "sFileIOUtils::RSyncFiles() >>> finished with result %d\n", ret); 
    573583  return ret; 
    574584} // RSyncFiles() 
     
    580590bool sFileIOUtils::CheckAndGetFile(const std::string &file_name, std::string &full_local_file_name, const std::string& resource_repository, const std::string& resource_server, const std::string& local_resource_directory, const std::string& server_resource_directory, bool use_cache) 
    581591{ 
    582   RRLIB_LOG_PRINTF(rrlib::logging::eLL_DEBUG_VERBOSE_1, "sFileIOUtils::CheckAndGetFile() >>> started with local_resource_directory <%s>, resource_repository <%s>, file_name <%s>, resource_server <%s>, server_resource_directory <%s>\n", local_resource_directory.c_str(), resource_repository.c_str(), file_name.c_str(), resource_server.c_str(), server_resource_directory.c_str()); 
     592  RRLIB_LOG_PRINTF(logging::eLL_DEBUG_VERBOSE_1, "sFileIOUtils::CheckAndGetFile() >>> started with local_resource_directory <%s>, resource_repository <%s>, file_name <%s>, resource_server <%s>, server_resource_directory <%s>\n", local_resource_directory.c_str(), resource_repository.c_str(), file_name.c_str(), resource_server.c_str(), server_resource_directory.c_str()); 
    583593 
    584594  //!##################################################################################################### 
     
    601611  full_local_file_name = "./" + resource_repository + file_name; 
    602612 
    603   RRLIB_LOG_PRINTF(rrlib::logging::eLL_DEBUG_VERBOSE_1, "sFileIOUtils::CheckAndGetFile() >>> 1. check: trying to load <%s>\n", full_local_file_name.c_str()); 
     613  RRLIB_LOG_PRINTF(logging::eLL_DEBUG_VERBOSE_1, "sFileIOUtils::CheckAndGetFile() >>> 1. check: trying to load <%s>\n", full_local_file_name.c_str()); 
    604614  ifstream try_1(full_local_file_name.c_str()); 
    605615  if (try_1) 
     
    619629    if (!sFileIOUtils::ShellExpandFilename(expanded_local_resource_directory, local_resource_directory + "/")) 
    620630    { 
    621       RRLIB_LOG_PRINTF(rrlib::logging::eLL_ERROR, "sFileIOUtils::%s >> Could not expand local resource directory!\n", __FUNCTION__); 
     631      RRLIB_LOG_PRINTF(logging::eLL_ERROR, "sFileIOUtils::%s >> Could not expand local resource directory!\n", __FUNCTION__); 
    622632      return false; 
    623633    } 
    624634    full_local_file_name = (expanded_local_resource_directory + resource_repository + file_name); 
    625635 
    626     RRLIB_LOG_PRINTF(rrlib::logging::eLL_DEBUG_VERBOSE_1, "sFileIOUtils::CheckAndGetFile() >>> 2. check: trying to load <%s>\n", full_local_file_name.c_str()); 
     636    RRLIB_LOG_PRINTF(logging::eLL_DEBUG_VERBOSE_1, "sFileIOUtils::CheckAndGetFile() >>> 2. check: trying to load <%s>\n", full_local_file_name.c_str()); 
    627637    ifstream try_2(full_local_file_name.c_str()); 
    628638    if (try_2) 
     
    642652      { 
    643653        local_host = sFileIOUtils::cached_local_host; 
    644         RRLIB_LOG_PRINTF(rrlib::logging::eLL_DEBUG_VERBOSE_1, "sFileIOUtils::CheckAndGetFile() >>> retrieved local_host <%s> from cache\n", local_host.c_str()); 
     654        RRLIB_LOG_PRINTF(logging::eLL_DEBUG_VERBOSE_1, "sFileIOUtils::CheckAndGetFile() >>> retrieved local_host <%s> from cache\n", local_host.c_str()); 
    645655      } 
    646656      else 
     
    659669        { 
    660670          server_ip_address = pos->second; 
    661           RRLIB_LOG_PRINTF(rrlib::logging::eLL_DEBUG_VERBOSE_1, "sFileIOUtils::CheckAndGetFile() >>> retrieved ip address <%s> of host <%s> from cache\n", server_ip_address.c_str(), server.c_str()); 
     671          RRLIB_LOG_PRINTF(logging::eLL_DEBUG_VERBOSE_1, "sFileIOUtils::CheckAndGetFile() >>> retrieved ip address <%s> of host <%s> from cache\n", server_ip_address.c_str(), server.c_str()); 
    662672        } 
    663673        else 
    664674        { 
    665675          server_ip_address = inet_ntoa(sFileIOUtils::HostToIp(server)); 
    666           RRLIB_LOG_PRINTF(rrlib::logging::eLL_DEBUG_VERBOSE_1, "sFileIOUtils::CheckAndGetFile() >>> got ip address <%s> of host <%s>\n", server_ip_address.c_str(), server.c_str()); 
     676          RRLIB_LOG_PRINTF(logging::eLL_DEBUG_VERBOSE_1, "sFileIOUtils::CheckAndGetFile() >>> got ip address <%s> of host <%s>\n", server_ip_address.c_str(), server.c_str()); 
    667677 
    668678          if (server_ip_address == "0.0.0.0") 
    669679          { 
    670             RRLIB_LOG_PRINTF(rrlib::logging::eLL_ERROR, "sFileIOUtils::constructor >>> zero ip address ... clearing server\n"); 
     680            RRLIB_LOG_PRINTF(logging::eLL_ERROR, "sFileIOUtils::constructor >>> zero ip address ... clearing server\n"); 
    671681            server = ""; 
    672682          } 
     
    681691      if (server != "")   //&& server != local_host) 
    682692      { 
    683         RRLIB_LOG_PRINTF(rrlib::logging::eLL_DEBUG_VERBOSE_1, "sFileIOUtils::CheckAndGetFile() >>> 3. check: trying to rsync <%s:%s> to <%s> \n", server_ip_address.c_str(), (server_resource_directory + resource_repository + file_name).c_str(), expanded_local_resource_directory.c_str()); 
     693        RRLIB_LOG_PRINTF(logging::eLL_DEBUG_VERBOSE_1, "sFileIOUtils::CheckAndGetFile() >>> 3. check: trying to rsync <%s:%s> to <%s> \n", server_ip_address.c_str(), (server_resource_directory + resource_repository + file_name).c_str(), expanded_local_resource_directory.c_str()); 
    684694 
    685695        // rsync from <resource_server:server_resource_directory + resource_repository> 
     
    688698        if (sFileIOUtils::RSyncFile("", server_ip_address, server_resource_directory + "/./" + resource_repository, file_name, expanded_local_resource_directory, "R") != 0) 
    689699        { 
    690           RRLIB_LOG_PRINTF(rrlib::logging::eLL_ERROR, "sFileIOUtils::CheckAndGetFile() >>> could not rsync file <%s> from server <%s> at <%s> ... skipping\n", file_name.c_str(), server.c_str(), (server_resource_directory + resource_repository).c_str()); 
     700          RRLIB_LOG_PRINTF(logging::eLL_ERROR, "sFileIOUtils::CheckAndGetFile() >>> could not rsync file <%s> from server <%s> at <%s> ... skipping\n", file_name.c_str(), server.c_str(), (server_resource_directory + resource_repository).c_str()); 
    691701          return false; 
    692702        } 
     
    695705      else 
    696706      { 
    697         RRLIB_LOG_PRINTF(rrlib::logging::eLL_ERROR, "sFileIOUtils::CheckAndGetFile() >>> could neither load <%s> locally nor from resource server ... skipping\n", file_name.c_str()); 
     707        RRLIB_LOG_PRINTF(logging::eLL_ERROR, "sFileIOUtils::CheckAndGetFile() >>> could neither load <%s> locally nor from resource server ... skipping\n", file_name.c_str()); 
    698708        return false; 
    699709      } 
     
    705715  if (!try_3) 
    706716  { 
    707     RRLIB_LOG_PRINTF(rrlib::logging::eLL_ERROR, "sFileIOUtils::CheckAndGetFile() >>> final check failed: could not load <%s> ... skipping\n", full_local_file_name.c_str()); 
     717    RRLIB_LOG_PRINTF(logging::eLL_ERROR, "sFileIOUtils::CheckAndGetFile() >>> final check failed: could not load <%s> ... skipping\n", full_local_file_name.c_str()); 
    708718    return false; 
    709719  } 
     
    734744  sFileIOUtils::resource_cache.clear(); 
    735745} // ClearResourceCache() 
     746 
     747//---------------------------------------------------------------------- 
     748// End of namespace declaration 
     749//---------------------------------------------------------------------- 
     750} 
     751} 
  • sStringUtils.cpp

    r34 r41  
    3636//#include <boost/algorithm/string.hpp> // trim 
    3737 
    38 using namespace rrlib::util; 
     38//---------------------------------------------------------------------- 
     39// Namespace declaration 
     40//---------------------------------------------------------------------- 
     41namespace rrlib 
     42{ 
     43namespace util 
     44{ 
    3945 
    4046const size_t sStringUtils::max_chars; 
     
    188194} 
    189195 
     196//---------------------------------------------------------------------- 
     197// End of namespace declaration 
     198//---------------------------------------------------------------------- 
     199} 
     200} 
  • tFPSComputer.cpp

    r34 r41  
    3434#include "rrlib/util/tFPSComputer.h" 
    3535 
    36 using namespace rrlib::util; 
     36//---------------------------------------------------------------------- 
     37// Namespace declaration 
     38//---------------------------------------------------------------------- 
     39namespace rrlib 
     40{ 
     41namespace util 
     42{ 
    3743 
    3844tFPSComputer::tFPSComputer(long long int check_interval_ms, float old_value_weight): 
     
    5763    check_interval_ms(check_interval_ms) 
    5864{ } 
     65 
     66 
     67//---------------------------------------------------------------------- 
     68// End of namespace declaration 
     69//---------------------------------------------------------------------- 
     70} 
     71} 
  • tFPSComputer.h

    r34 r41  
    4545  tFPSComputer(long long int check_interval_ms = 1000, float old_value_weight = 0.75); 
    4646 
    47   tFPSComputer(const rrlib::util::tTime &current_time, long long int check_interval_ms = 1000, float old_value_weight = 0.75); 
     47  tFPSComputer(const util::tTime &current_time, long long int check_interval_ms = 1000, float old_value_weight = 0.75); 
    4848 
    4949  inline void IncrementFrameCounter() 
     
    5454  inline bool IncrementFrameCounterAndCheckFPS() 
    5555  { 
    56     return IncrementFrameCounterAndCheckFPS(rrlib::util::tTime::Now()); 
     56    return IncrementFrameCounterAndCheckFPS(util::tTime::Now()); 
    5757  } 
    5858 
    59   inline bool IncrementFrameCounterAndCheckFPS(const rrlib::util::tTime &current_time) 
     59  inline bool IncrementFrameCounterAndCheckFPS(const util::tTime &current_time) 
    6060  { 
    6161    ++this->frame_counter; 
     
    6565  inline bool CheckFPS() 
    6666  { 
    67     return CheckFPS(rrlib::util::tTime::Now()); 
     67    return CheckFPS(util::tTime::Now()); 
    6868  } 
    6969 
    70   inline bool CheckFPS(const rrlib::util::tTime &current_time) 
     70  inline bool CheckFPS(const util::tTime &current_time) 
    7171  { 
    7272    current_fps_check = current_time; 
     
    106106 
    107107private: 
    108   rrlib::util::tTime current_fps_check; 
    109   rrlib::util::tTime last_fps_check; 
    110   rrlib::util::tTime time_diff_check; 
     108  util::tTime current_fps_check; 
     109  util::tTime last_fps_check; 
     110  util::tTime time_diff_check; 
    111111  double last_frame_counter; 
    112112  double frame_counter; 
  • tTime.cpp

    r34 r41  
    2929#include "rrlib/serialization/tInputStream.h" 
    3030#include "rrlib/serialization/tOutputStream.h" 
    31  
    32 rrlib::serialization::tOutputStream &rrlib::util::operator << (rrlib::serialization::tOutputStream &stream, const rrlib::util::tTime &t) 
    33 { 
    34   stream.WriteLong(t.TvSec()); 
    35   stream.WriteLong(t.TvUSec()); 
    36   return stream; 
    37 } 
    38  
    39 rrlib::serialization::tInputStream &rrlib::util::operator >> (rrlib::serialization::tInputStream &stream, rrlib::util::tTime &t) 
    40 { 
    41   t.SetTvSec(static_cast<long>(stream.ReadLong())); 
    42   t.SetTvUSec(static_cast<long>(stream.ReadLong())); 
    43   return stream; 
    44 } 
    45  
    4631#endif 
    4732 
    48 using rrlib::util::tTime; 
     33//---------------------------------------------------------------------- 
     34// Namespace declaration 
     35//---------------------------------------------------------------------- 
     36namespace rrlib 
     37{ 
     38namespace util 
     39{ 
    4940 
    5041const tTime tTime::time_forever(-1, 0); 
     
    7768const tTime tTime::time_1year(365 * 86400, 0); 
    7869 
     70 
     71#ifdef _LIB_RRLIB_SERIALIZATION_PRESENT_ 
     72serialization::tOutputStream &util::operator << (serialization::tOutputStream &stream, const util::tTime &t) 
     73{ 
     74  stream.WriteLong(t.TvSec()); 
     75  stream.WriteLong(t.TvUSec()); 
     76  return stream; 
     77} 
     78 
     79serialization::tInputStream &util::operator >> (serialization::tInputStream &stream, util::tTime &t) 
     80{ 
     81  t.SetTvSec(static_cast<long>(stream.ReadLong())); 
     82  t.SetTvUSec(static_cast<long>(stream.ReadLong())); 
     83  return stream; 
     84} 
     85 
     86#endif 
     87 
     88//---------------------------------------------------------------------- 
     89// End of namespace declaration 
     90//---------------------------------------------------------------------- 
     91} 
     92} 
Note: See TracChangeset for help on using the changeset viewer.