Merge pull request #5039 from CEikermann/patch-1
[vuplus_xbmc] / xbmc / XbmcContext.cpp
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #include "XbmcContext.h"
22
23 #include "threads/Thread.h"
24 #include "commons/Exception.h"
25 #include "utils/log.h"
26
27 namespace XBMC
28 {
29
30   class ContextOpaque
31   {
32   public:
33     XbmcCommons::ILogger* loggerImpl;
34
35     ContextOpaque() : loggerImpl(NULL) {}
36   };
37
38   Context::Context()
39   {
40     impl = new ContextOpaque;
41
42     // instantiate
43     impl->loggerImpl = new XbmcUtils::LogImplementation;
44
45     // set
46     XbmcCommons::Exception::SetLogger(impl->loggerImpl);
47     CThread::SetLogger(impl->loggerImpl);
48   }
49
50   Context::~Context()
51   {
52     // cleanup
53     XbmcCommons::Exception::SetLogger(NULL);
54     CThread::SetLogger(NULL);
55     delete impl->loggerImpl;
56
57     delete impl;
58   }
59 }
60