GobChartsWidget  1.0
gobchartsfactory.cpp
1 /* Copyright (C) 2012 by William Hallatt.
2  *
3  * This file forms part of the "GobChartsWidget" library.
4  *
5  * This library 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 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This library 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 downloaded a copy of the GNU General Public License
16  * (GNUGPL.txt) and GNU Lesser General Public License (GNULGPL.txt)
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * The official website for this project is www.goblincoding.com and,
20  * although not compulsory, it would be appreciated if all works of whatever
21  * nature referring to or using this library include a reference to this site.
22  */
23 
24 #include "gobchartsfactory.h"
25 #include "gobchartsbarview.h"
26 #include "gobchartspieview.h"
27 #include "gobchartslineview.h"
28 
29 /*--------------------------------------------------------------------------------*/
30 
31 GobChartsFactory *GobChartsFactory::m_instance = NULLPOINTER;
32 
33 /*--------------------------------------------------------------------------------*/
34 
36 {
37  if( !m_instance )
38  {
39  m_instance = new GobChartsFactory();
40  }
41 
42  return m_instance;
43 }
44 
45 /*--------------------------------------------------------------------------------*/
46 
47 GobChartsFactory::GobChartsFactory()
48 {
49  // Default
50 }
51 
52 /*--------------------------------------------------------------------------------*/
53 
54 GobChartsView *GobChartsFactory::createChart( GobChartsType type, QWidget *parent )
55 {
56  switch( type )
57  {
58  case BAR:
59  return new GobChartsBarView( parent );
60  case PIE:
61  return new GobChartsPieView( parent );
62  case LINE:
63  return new GobChartsLineView( parent );
64  }
65 
66  return NULLPOINTER;
67 }
68 
69 /*--------------------------------------------------------------------------------*/