summaryrefslogtreecommitdiffstats
path: root/kpovmodeler/pmprototypemanager.h
blob: a0ead7ae8cfa0babde8aab0e045819d25029c632 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
**************************************************************************
                                 description
                             --------------------
    copyright            : (C) 2000-2002 by Andreas Zehender
    email                : [email protected]
**************************************************************************

**************************************************************************
*                                                                        *
*  This program is free software; you can redistribute it and/or modify  *
*  it under the terms of the GNU General Public License as published by  *
*  the Free Software Foundation; either version 2 of the License, or     *
*  (at your option) any later version.                                   *
*                                                                        *
**************************************************************************/


#ifndef PMPTMANAGER_H
#define PMPTMANAGER_H

#include "pmobject.h"
#include <tqdict.h>
#include <tqmap.h>
#include <tqvaluelist.h>

class PMPart;

/**
 * Description class for declarations types, used by @ref PMPrototypeManager
 * and @ref PMDeclare
 */
class PMDeclareDescription
{
public:
   PMDeclareDescription( ) { }
   PMDeclareDescription( const PMDeclareDescription& d )
   {
      type = d.type;
      description = d.description;
      pixmap = d.pixmap;
   }
   PMDeclareDescription( PMMetaObject* t, const TQString& d, const TQString& p )
   {
      type = t;
      description = d;
      pixmap = p;
   }
   PMDeclareDescription& operator=( const PMDeclareDescription& d )
   {
      type = d.type;
      description = d.description;
      pixmap = d.pixmap;
      return *this;
   }
   PMMetaObject* type;
   TQString description;
   TQString pixmap;
};

/**
 * Prototype manager for @ref PMObject.
 *
 * This class stores class and inheritance information for each
 * available object type.
 *
 * Each @ref PMPart class holds one instance of this class. The
 * available objects depend on the loaded plugins.
 *
 * Patterns: Prototype
 */
class PMPrototypeManager
{
public:
   /**
    * Creates a prototype manager for the part.
    */
   PMPrototypeManager( PMPart* part );
   /**
    * Deletes the prototype manager
    */
   ~PMPrototypeManager( );
   /**
    * Adds the object to the list of prototypes. The prototype becomes
    * the owner of the object and will be delete immediately by the
    * prototype manager.
    */
   void addPrototype( PMObject* obj );
   /**
    * Adds a declaration type. Needed information is the class type,
    * the @ref description( ) and the @ref pixmap( )
    */
   void addDeclarationType( const TQString& className,
                            const TQString& description,
                            const TQString& pixmap );
   /**
    * Returns an iterator to the list of available objects
    */
   TQPtrListIterator<PMMetaObject> prototypeIterator( ) const;
   /**
    * Returns an iterator to the list of available declaration types
    */
   const TQValueList<PMDeclareDescription>& declarationTypes( ) const;
   /**
    * Returns a new PMObject by class name
    */
   PMObject* newObject( const TQString& name ) const;
   /**
    * Returns the meta object by class name or 0 if this class does
    * not exist.
    * @see PMMetaObject
    */
   PMMetaObject* metaObject( const TQString& name ) const;
   /**
    * Returns true if the class exists
    */
   bool existsClass( const TQString& name ) const
   {
      return metaObject( name );
   }
   /**
    * Returns true if the second class is a base class for
    * the first class
    */
   bool isA( const TQString& className, const TQString& baseClassName ) const;
   /**
    * Returns true if the second class is a base class for
    * the first class
    */
   bool isA( PMMetaObject* c, const TQString& baseClassName ) const;
   /**
    * Returns the real class if only the lower case version is know.
    * Used by the xml parser
    */
   TQString className( const TQString& lowercase ) const;
   /**
    * Returns a pointer to the part
    */
   PMPart* part( ) const { return m_pPart; }

private:
   TQPtrList<PMMetaObject> m_prototypes;
   TQDict<PMMetaObject> m_metaDict;
   TQMap<TQString, TQString> m_lowerCaseDict;
   TQValueList<PMDeclareDescription> m_declareDescriptions;
   PMPart* m_pPart;
};
#endif