BasicUsageEnvironment/BasicUsageEnvironment.cpp

Go to the documentation of this file.
00001 /**********
00002 This library is free software; you can redistribute it and/or modify it under
00003 the terms of the GNU Lesser General Public License as published by the
00004 Free Software Foundation; either version 2.1 of the License, or (at your
00005 option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
00006 
00007 This library is distributed in the hope that it will be useful, but WITHOUT
00008 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00009 FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
00010 more details.
00011 
00012 You should have received a copy of the GNU Lesser General Public License
00013 along with this library; if not, write to the Free Software Foundation, Inc.,
00014 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00015 **********/
00016 // Copyright (c) 1996-2008 Live Networks, Inc.  All rights reserved.
00017 // Basic Usage Environment: for a simple, non-scripted, console application
00018 // Implementation
00019 
00020 #ifndef IMN_PIM
00021 #include "BasicUsageEnvironment.hh"
00022 #include <stdio.h>
00023 
00025 
00026 #if defined(__WIN32__) || defined(_WIN32)
00027 extern "C" int initializeWinsockIfNecessary();
00028 #endif
00029 
00030 BasicUsageEnvironment::BasicUsageEnvironment(TaskScheduler& taskScheduler)
00031 : BasicUsageEnvironment0(taskScheduler) {
00032 #if defined(__WIN32__) || defined(_WIN32)
00033   if (!initializeWinsockIfNecessary()) {
00034     setResultErrMsg("Failed to initialize 'winsock': ");
00035     reportBackgroundError();
00036     exit(1);
00037   }
00038 #endif
00039 }
00040 
00041 BasicUsageEnvironment::~BasicUsageEnvironment() {
00042 }
00043 
00044 BasicUsageEnvironment*
00045 BasicUsageEnvironment::createNew(TaskScheduler& taskScheduler) {
00046   return new BasicUsageEnvironment(taskScheduler);
00047 }
00048 
00049 int BasicUsageEnvironment::getErrno() const {
00050 #if defined(__WIN32__) || defined(_WIN32)
00051 #ifndef _WIN32_WCE
00052   if (errno == 0) {
00053     errno = WSAGetLastError();
00054   }
00055 #endif
00056 #endif
00057 #if defined(_WIN32_WCE)
00058   return WSAGetLastError();
00059 #else
00060   return errno;
00061 #endif
00062 }
00063 
00064 UsageEnvironment& BasicUsageEnvironment::operator<<(char const* str) {
00065         fprintf(stderr, "%s", str);
00066         return *this;
00067 }
00068 
00069 UsageEnvironment& BasicUsageEnvironment::operator<<(int i) {
00070         fprintf(stderr, "%d", i);
00071         return *this;
00072 }
00073 
00074 UsageEnvironment& BasicUsageEnvironment::operator<<(unsigned u) {
00075         fprintf(stderr, "%u", u);
00076         return *this;
00077 }
00078 
00079 UsageEnvironment& BasicUsageEnvironment::operator<<(double d) {
00080         fprintf(stderr, "%f", d);
00081         return *this;
00082 }
00083 
00084 UsageEnvironment& BasicUsageEnvironment::operator<<(void* p) {
00085         fprintf(stderr, "%p", p);
00086         return *this;
00087 }
00088 #endif
00089 

Generated on Tue Jul 22 06:39:05 2008 for live by  doxygen 1.5.2