~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to arts/runtime/moduleinfo.cc

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
    /*
 
2
 
 
3
    Copyright (C) 2000 Stefan Westerfeld
 
4
                       stefan@space.twc.de
 
5
 
 
6
    This program is free software; you can redistribute it and/or modify
 
7
    it under the terms of the GNU General Public License as published by
 
8
    the Free Software Foundation; either version 2 of the License, or
 
9
    (at your option) any later version.
 
10
 
 
11
    This program is distributed in the hope that it will be useful,
 
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
    GNU General Public License for more details.
 
15
 
 
16
    You should have received a copy of the GNU General Public License
 
17
    along with this program; if not, write to the Free Software
 
18
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
19
 
 
20
    Permission is also granted to link this program with the Qt
 
21
    library, treating Qt like a library that normally accompanies the
 
22
    operating system kernel, whether or not that is in fact the case.
 
23
 
 
24
    */
 
25
 
 
26
#include "moduleinfo.h"
 
27
 
 
28
using namespace std;
 
29
 
 
30
static void gatherPorts(Arts::InterfaceDef& idef, Arts::ModuleInfo& minfo,
 
31
                                                                                map<string, bool>& done)
 
32
{
 
33
        Arts::InterfaceRepo interfaceRepo=Arts::Dispatcher::the()->interfaceRepo();
 
34
 
 
35
        vector<string>::iterator ii = idef.inheritedInterfaces.begin();
 
36
        while(ii != idef.inheritedInterfaces.end())
 
37
        {
 
38
                Arts::InterfaceDef inherited = interfaceRepo.queryInterface(*ii++);
 
39
                gatherPorts(inherited,minfo,done);
 
40
        }
 
41
 
 
42
        if(idef.name == "Arts::Object" || idef.name == "Arts::SynthModule")
 
43
        {
 
44
                // don't gather members of these basic interfaces as ports
 
45
                return;
 
46
        }
 
47
        vector<Arts::AttributeDef>::iterator i;
 
48
        for(i=idef.attributes.begin(); i != idef.attributes.end(); i++)
 
49
        {
 
50
                // 1 = direction, 10000 = connectiontype
 
51
                long complete = 0;
 
52
                Arts::PortType ptype;
 
53
 
 
54
                if(i->flags & Arts::streamIn)
 
55
                {
 
56
                        ptype.direction = Arts::input;
 
57
                        complete += 1;
 
58
                }
 
59
                else if(i->flags & Arts::streamOut)
 
60
                {
 
61
                        ptype.direction = Arts::output;
 
62
                        complete += 1;
 
63
                }
 
64
 
 
65
                ptype.dataType = i->type;
 
66
 
 
67
                if(i->flags & Arts::attributeStream)
 
68
                {
 
69
                        ptype.connType = Arts::conn_stream;
 
70
                        complete += 10000;
 
71
                }
 
72
                else if(i->flags & Arts::attributeAttribute)
 
73
                {
 
74
                        ptype.connType = Arts::conn_property;
 
75
                        complete += 10000;
 
76
                }
 
77
 
 
78
                ptype.isMultiPort = (i->flags & Arts::streamMulti);
 
79
 
 
80
                if(complete == 10001 && !done[i->name])
 
81
                {
 
82
                        minfo.portnames.push_back(i->name);
 
83
                        minfo.ports.push_back(ptype);
 
84
                        done[i->name] = true;
 
85
                }
 
86
        }
 
87
}
 
88
 
 
89
Arts::ModuleInfo makeModuleInfo(const string& name)
 
90
{
 
91
        Arts::InterfaceRepo interfaceRepo=Arts::Dispatcher::the()->interfaceRepo();
 
92
        Arts::InterfaceDef idef = interfaceRepo.queryInterface(name);
 
93
        Arts::ModuleInfo minfo;
 
94
 
 
95
        if(idef.name != "")
 
96
        {
 
97
                map<string,bool> done;
 
98
                minfo.name = name;
 
99
                minfo.isStructure = false;
 
100
                minfo.isInterface = false;
 
101
 
 
102
                gatherPorts(idef,minfo,done);
 
103
        }
 
104
        return minfo;
 
105
}
 
106