1 |
/* cmhandler.cpp |
---|
2 |
* Copyright (C) 2004 by Daniel Wagner |
---|
3 |
* |
---|
4 |
* This file is part of FreeBob. |
---|
5 |
* |
---|
6 |
* FreeBob is free software; you can redistribute it and/or modify |
---|
7 |
* it under the terms of the GNU General Public License as published by |
---|
8 |
* the Free Software Foundation; either version 2 of the License, or |
---|
9 |
* (at your option) any later version. |
---|
10 |
* FreeBob 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 FreeBob; if not, write to the Free Software |
---|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
---|
18 |
* MA 02111-1307 USA. |
---|
19 |
*/ |
---|
20 |
|
---|
21 |
#include "cmhandler.h" |
---|
22 |
#include "ieee1394service.h" |
---|
23 |
#include "debugmodule.h" |
---|
24 |
|
---|
25 |
CMHandler* CMHandler::m_pInstance = 0; |
---|
26 |
|
---|
27 |
CMHandler::CMHandler() |
---|
28 |
: m_bInitialised( false ) |
---|
29 |
{ |
---|
30 |
} |
---|
31 |
|
---|
32 |
CMHandler::~CMHandler() |
---|
33 |
{ |
---|
34 |
if ( m_pIeee1394Service ) { |
---|
35 |
m_pIeee1394Service->shutdown(); |
---|
36 |
} |
---|
37 |
m_pInstance = 0; |
---|
38 |
} |
---|
39 |
|
---|
40 |
FBReturnCodes |
---|
41 |
CMHandler::initialize() |
---|
42 |
{ |
---|
43 |
if ( !m_bInitialised ) { |
---|
44 |
m_pIeee1394Service = Ieee1394Service::instance(); |
---|
45 |
|
---|
46 |
if ( !m_pIeee1394Service ) { |
---|
47 |
debugError( "Could not get an valid instance of 1394 service.\n" ); |
---|
48 |
return eFBRC_InitializeCMHandlerFailed; |
---|
49 |
} |
---|
50 |
FBReturnCodes eStatus = m_pIeee1394Service->initialize(); |
---|
51 |
if ( eStatus != eFBRC_Success ) { |
---|
52 |
debugError( "Initialising of 1394 service failed.\n" ); |
---|
53 |
return eStatus; |
---|
54 |
} |
---|
55 |
m_bInitialised = true; |
---|
56 |
} |
---|
57 |
return eFBRC_Success; |
---|
58 |
} |
---|
59 |
|
---|
60 |
void |
---|
61 |
CMHandler::shutdown() |
---|
62 |
{ |
---|
63 |
delete this; |
---|
64 |
} |
---|
65 |
|
---|
66 |
CMHandler* |
---|
67 |
CMHandler::instance() |
---|
68 |
{ |
---|
69 |
if ( !m_pInstance ) { |
---|
70 |
m_pInstance = new CMHandler; |
---|
71 |
} |
---|
72 |
return m_pInstance; |
---|
73 |
} |
---|