using namespace Kita;
-ThreadFactory* ThreadFactory::instance = 0;
+QDict<Thread>* Thread::m_threadDict = 0;
Thread::Thread()
{}
return thread;
}
+Thread* Thread::getByURL( const QString& datURL )
+{
+ if ( m_threadDict == 0 ) {
+ m_threadDict = new QDict<Thread>();
+ }
+
+ if ( m_threadDict->find( datURL ) ) {
+ return m_threadDict->find( datURL );
+ }
+
+ Thread* newThread = new Thread( datURL );
+ m_threadDict->insert( datURL, newThread );
+
+ return newThread;
+}
+
+void Thread::setName( const QString& datURL, const QString& threadName )
+{
+ if ( datURL.isNull() ) {
+ return;
+ }
+
+ if ( m_threadDict == 0 ) {
+ m_threadDict = new QDict<Thread>();
+ }
+
+ Thread* newThread = new Thread( datURL, threadName );
+ m_threadDict->replace( datURL, newThread );
+
+ return;
+}
+
ThreadXmlParser::ThreadXmlParser()
: m_boardParser( 0 ), m_inBoard( false ), m_isValid( false ), m_inThread( false )
{};
}
}
-void ThreadFactory::insertThread( Thread& thread )
-{
- if ( ! instance ) {
- instance = new ThreadFactory();
- }
-
- Thread* new_thread = new Thread( thread.datURL(), thread.name() );
- KitaThreadInfo::setResNum( thread.datURL(), thread.resNum() );
- instance->m_dict.insert( thread.datURL(), new_thread );
-}
-
-Thread* ThreadFactory::getThread( QString& datURL )
-{
- if ( ! instance ) {
- instance = new ThreadFactory();
- }
-
- return instance->m_dict[ datURL ];
-}
-
#include "thread.moc"
const QString toXmlFragment() const;
static Thread fromXml( const QString& xml );
+ static Thread* getByURL( const QString& datURL );
+ static void setName( const QString& datURL, const QString& threadName );
private:
QString m_datURL;
QString m_threadName;
- };
-
- class ThreadFactory
- {
- public:
- static void insertThread( Thread& thread );
- static Thread* getThread( QString& datURL );
-
- private:
- static ThreadFactory* instance;
- QDict<Thread> m_dict;
-
- ThreadFactory() {};
- ~ThreadFactory() {};
+ static QDict<Thread>* m_threadDict;
};
class ThreadXmlParser : public QXmlDefaultHandler