Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

xercesmanager.cpp

Go to the documentation of this file.
00001 /*
00002     Sheep - A Rigid Body Dynamics Engine
00003     Copyright (C) 2001-2004 Francois Beaune
00004     Contact: http://toxicengine.sourceforge.net/
00005 
00006     This file is part of Sheep.
00007 
00008     Sheep is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012 
00013     Sheep is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License
00019     along with Sheep; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 */
00022 
00023 #include "xercesmanager.h"  // include first
00024 #include "xercesutils.h"
00025 
00026 #include <xercesc/util/PlatformUtils.hpp>
00027 #include <xercesc/util/XercesDefs.hpp>
00028 
00029 #include <cassert>
00030 #include <cstdlib>  // exit(), EXIT_FAILURE
00031 #include <iostream>
00032 
00033 using namespace sheep;
00034 using namespace std;
00035 using namespace xercesc;
00036 
00037 //#define VERBOSE
00038 
00039 int XercesManager::m_uses = 0;
00040 static XercesManager xercesmanager;
00041 
00042 XercesManager::~XercesManager() {
00043     if(m_uses > 0) {
00044 #ifdef VERBOSE
00045         cerr << "Automatically shutting down Xerces-C XML Parser..." << endl;
00046 #endif  // VERBOSE
00047         XMLPlatformUtils::Terminate();  
00048     }
00049 }
00050 
00051 void XercesManager::Initialize() {
00052     if(m_uses == 0) {
00053         try {
00054             XMLPlatformUtils::Initialize();
00055         }
00056         catch(const XMLException &e) {
00057             cerr << "Error during Xerces-C initialization." << endl;
00058             cerr << "Exception message: " << e.getMessage() << endl;
00059             exit(EXIT_FAILURE);
00060         }
00061     }
00062 
00063     ++m_uses;
00064 }
00065 
00066 void XercesManager::Shutdown() {
00067     assert(m_uses > 0);
00068 
00069     --m_uses;
00070 
00071     if(m_uses == 0)
00072         XMLPlatformUtils::Terminate();
00073 }

Generated on Tue May 11 01:31:53 2004 for toxic by doxygen 1.3.6