Back to index

salome-kernel  6.5.0
SALOME_Logger_Server.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SALOME Logger : CORBA server managing trace output
00024 //  File   : SALOME_Logger_Server.hxx
00025 //  Author : Vasily Rusyaev
00026 //  Module : SALOME
00027 //
00028 #if !defined SALOME_Logger_Server_include
00029 #define SALOME_Logger_Server_include
00030 
00031 #include <SALOMEconfig.h>
00032 #include <fstream>
00033 
00034 #ifdef WIN32
00035 #include <iosfwd>
00036 #endif
00037 #include <omnithread.h>
00038 #include "Logger.hh"
00039 
00040 #ifdef WIN32
00041 # if defined LOGGER_EXPORTS || defined SalomeLoggerServer_EXPORTS
00042 #  define LOGGER_EXPORT __declspec( dllexport )
00043 # else
00044 #  define LOGGER_EXPORT __declspec( dllimport )
00045 # endif
00046 #else
00047 # define LOGGER_EXPORT
00048 #endif
00049 
00050 #ifdef WNT
00051 #pragma warning(disable:4275) // Disable warning interface non dll
00052 #endif
00053 
00054 class LOGGER_EXPORT Logger :
00055   public POA_SALOME_Logger::Logger
00056 {
00057 public:
00058         //constructor w/o parameters
00059         //all messages will be put into terminal via cout
00060         Logger();
00061         //constructor with parameter, filename is output file
00062         //all messages will be put into special file passed as parameter
00063         Logger(const char *filename);
00064         virtual ~Logger();
00065         //put message into one special place for all servers
00066         void putMessage(const char* message);
00067         void ping();
00068         void SetOrb( CORBA::ORB_ptr orb ) { _orb = CORBA::ORB::_duplicate(orb); return; }
00069         void shutdown() { if(!CORBA::is_nil(_orb)) _orb->shutdown(0); };  
00070 private:
00071         //if m_putIntoFile is true all messages will be put into special 
00072         //otherwise all messages will be put into terminal via cout 
00073         bool m_putIntoFile;
00074         //ofstream class specialized for disk file output
00075         std::ofstream m_outputFile; 
00076 
00077         //synchronisation object
00078         static omni_mutex myLock;
00079 
00080         CORBA::ORB_ptr _orb;
00081 };
00082 
00083 #endif // !defined(SALOME_Logger_Server_include)