]> Shamusworld >> Repos - architektonas/blob - src/base/rs_dialogfactory.cpp
In the middle of major refactoring...
[architektonas] / src / base / rs_dialogfactory.cpp
1 // rs_dialogfactory.cpp
2 //
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // (C) 2010 Underground Software
7 //
8 // JLH = James L. Hammons <jlhamm@acm.org>
9 //
10 // Who  When        What
11 // ---  ----------  -----------------------------------------------------------
12 // JLH  05/28/2010  Added this text. :-)
13 //
14
15 #include "rs_dialogfactory.h"
16
17 #include "rs_debug.h"
18
19 RS_DialogFactory * RS_DialogFactory::uniqueInstance = NULL;
20
21 /**
22  * Private constructor.
23  */
24 RS_DialogFactory::RS_DialogFactory()
25 {
26         RS_DEBUG->print("RS_DialogFacgory::RS_DialogFactory");
27         factoryObject = NULL;
28         RS_DEBUG->print("RS_DialogFacgory::RS_DialogFactory: OK");
29 }
30
31 /*virtual*/ RS_DialogFactory::~RS_DialogFactory()
32 {
33 }
34
35 /**
36  * @return Instance to the unique font list.
37  */
38 RS_DialogFactory * RS_DialogFactory::instance()
39 {
40         RS_DEBUG->print("RS_DialogFactory::instance()");
41
42         if (uniqueInstance == NULL)
43                 uniqueInstance = new RS_DialogFactory();
44
45         RS_DEBUG->print("RS_DialogFactory::instance(): OK");
46
47         return uniqueInstance;
48 }
49
50 /**
51  * Sets the real factory object that can create and show dialogs.
52  */
53 void RS_DialogFactory::setFactoryObject(RS_DialogFactoryInterface * fo)
54 {
55         RS_DEBUG->print("RS_DialogFactory::setFactoryObject");
56         factoryObject = fo;
57         RS_DEBUG->print("RS_DialogFactory::setFactoryObject: OK");
58 }
59
60 /**
61  * @return Factory object. This is never NULL. If no factory
62  * object was set, the default adapter will be returned.
63  */
64 RS_DialogFactoryInterface * RS_DialogFactory::getFactoryObject()
65 {
66         RS_DEBUG->print("RS_DialogFactory::getFactoryObject");
67
68         if (factoryObject != NULL)
69         {
70                 RS_DEBUG->print("RS_DialogFactory::getFactoryObject: returning factory object");
71                 return factoryObject;
72         }
73         else
74         {
75                 RS_DEBUG->print("RS_DialogFactory::getFactoryObject: returning adapter");
76                 return &factoryAdapter;
77         }
78 }
79
80 void RS_DialogFactory::commandMessage(const QString & m)
81 {
82         RS_DEBUG->print("RS_DialogFactory::commandMessage");
83
84         if (factoryObject != NULL)
85                 factoryObject->commandMessage(m);
86 }