File: dcasttest.cc

package info (click to toggle)
arts 1.5.9-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 8,436 kB
  • ctags: 9,848
  • sloc: ansic: 44,670; cpp: 33,776; sh: 10,486; perl: 3,470; makefile: 372; yacc: 347; lex: 160
file content (72 lines) | stat: -rw-r--r-- 2,202 bytes parent folder | download | duplicates (5)
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
    /*

    Copyright (C) 2000 Stefan Westerfeld stefan@space.twc.de

    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.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

    Permission is also granted to link this program with the Qt
    library, treating Qt like a library that normally accompanies the
    operating system kernel, whether or not that is in fact the case.

    */

#include <stdio.h>
#include <soundserver.h>
#include <iostream>

using namespace std;
using namespace Arts;

/*
 * This is a little test program that illustrates remote dynamic casting.
 * Arts_SimpleSoundServer is a global object that is a SimpleSoundServer,
 * so the first dynamic cast should succeed, while it is no Synth_PLAY,
 * so the second dynamic cast should fail.
 */

int main()
{
	Dispatcher dispatcher;
	Object obj = Reference("global:Arts_SimpleSoundServer");

	if(obj.isNull())
	{
		cerr << "this test will only work if artsd is running" << endl;
		exit(1);
	}

	/*
	 * TODO: fix this. This fails currently as in the first line only an
	 * Object_stub will get created, no SimpleSoundServer_stub, and _cast
	 * which is used by DynamicCast wil only try to cast the _stub object,
	 * not do any further tricks.
	 */
	SimpleSoundServer server = DynamicCast(obj);
	if(server.isNull())
	{
		cerr << "remote dynamic casting is too restrictive" << endl;
		exit(1);
	}

	Synth_PLAY play = DynamicCast(obj);
	if(!play.isNull())
	{
		cerr << "remote dynamic casting doesn't do proper checks" << endl;
		exit(1);
	}

	cout << "remote dynamic casting seems to be fine" << endl;
	return 0;
}