Project

General

Profile

Statistics
| Branch: | Revision:

root / src / tkenv / inspfactory.h @ 3e29b8a0

History | View | Annotate | Download (2.59 KB)

1 01873262 Georg Kunz
//==========================================================================
2
//  INSPFACTORY.H - part of
3
//
4
//                     OMNeT++/OMNEST
5
//            Discrete System Simulation in C++
6
//
7
//==========================================================================
8
9
/*--------------------------------------------------------------*
10
  Copyright (C) 1992-2008 Andras Varga
11
  Copyright (C) 2006-2008 OpenSim Ltd.
12

13
  This file is distributed WITHOUT ANY WARRANTY. See the file
14
  `license' for details on this and other legal matters.
15
*--------------------------------------------------------------*/
16
17
#ifndef __INSPFACTORY_H
18
#define __INSPFACTORY_H
19
20
#include <tk.h>
21
#include "onstartup.h"
22
#include "cregistrationlist.h"
23
#include "inspector.h"
24
#include "envirbase.h"
25
26
NAMESPACE_BEGIN
27
28
#define Register_InspectorFactory(FACTORYNAME) \
29
  EXECUTE_ON_STARTUP(inspectorfactories.getInstance()->add(new FACTORYNAME(#FACTORYNAME));)
30
31
32
/**
33
 * Serves as a base class for inspector factories of specific classes.
34
 */
35
class TKENV_API cInspectorFactory : public cNoncopyableOwnedObject
36
{
37
  public:
38
    /** @name Constructors, destructor, assignment. */
39
    //@{
40
    /**
41
     * Constructor.
42
     */
43
    cInspectorFactory(const char *name) : cNoncopyableOwnedObject(name,false) {}
44
45
    /**
46
     * Destructor.
47
     */
48
    virtual ~cInspectorFactory() {}
49
    //@}
50
51
52
    /** @name Inspector creation. */
53
    //@{
54
    /**
55
     * Returns true if this factory can create an inspector for this object.
56
     * Works with RTTI.
57
     */
58
    virtual bool supportsObject(cObject *object) = 0;
59
60
    /**
61
     * Returns type of inspector created by this factory (INSP_* constants).
62
     * Works with RTTI.
63
     */
64
    virtual int inspectorType() = 0;
65
66
    /**
67
     * Returns "how good" this inspector is as default inspector for this object.
68
     * Expressed as distance in the hiearchy tree from cObject, i.e.
69
     *  1.0 for TObjectInspector and TContainerInspector for common objects;
70
     *  2.0 for TMessageInspector, TWatchInspector, etc, and TContainerInspector for cArray&cQueue;
71
     *  3.0 for TPacketInspector; ...
72
     */
73
    virtual double qualityAsDefault(cObject *object) = 0;
74
75
    /**
76
     * Creates an inspector for the object passed. The type and data
77
     * arguments influence the type of inspector created.
78
     */
79
    virtual TInspector *createInspectorFor(cObject *object,int type,const char *geom,void *data) = 0;
80
    //@}
81
};
82
83
///< List of cInspectorFactory objects.
84
extern cGlobalRegistrationList inspectorfactories;
85
86
/**
87
 * Find a cInspectorFactory.
88
 */
89
cInspectorFactory *findInspectorFactoryFor(cObject *obj, int type);
90
91
NAMESPACE_END
92
93
94
#endif
95
96