COVISE Core
covise_objalg.h
Go to the documentation of this file.
1/* This file is part of COVISE.
2
3 You can use it under the terms of the GNU Lesser General Public License
4 version 2.1 or later, see lgpl-2.1.txt.
5
6 * License: LGPL 2+ */
7
8// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9// class coObjectAlgorithms
10//
11// coObjectAlgorithms is a vase for algorithms for DistributeObject processing
12//
13// Initial version: 2003-06, sl
14// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
15// (C) 2003 by Vircinity IT Consulting
16// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
17
18#ifndef _COVISE_OBJECT_ALGORITHMS_
19#define _COVISE_OBJECT_ALGORITHMS_
20
21#include "covise.h"
23
24namespace covise
25{
26
28{
29public:
36 template <class T>
37 static bool containsType(const coDistributedObject *obj,
38 bool strict_case = true);
39};
40
41template <class T>
42bool
44{
45 if (!obj)
46 {
47 return true; // no object is no problem
48 }
49
50 if (const coDoSet *set = dynamic_cast<const coDoSet *>(obj))
51 {
52 int no_elems;
53 const coDistributedObject *const *setList = set->getAllElements(&no_elems);
54 int i;
55 bool ret = true;
56 for (i = 0; i < no_elems; ++i)
57 {
58 bool thisType = containsType<T>(setList[i], strict_case);
59 if (!thisType && strict_case)
60 {
61 ret = false;
62 break;
63 }
64 else if (!strict_case && thisType)
65 {
66 break;
67 }
68 }
69 int elem;
70 for (elem = 0; elem < no_elems; ++elem)
71 {
72 delete setList[elem];
73 }
74 delete[] setList;
75 if (!ret) // see !thisType && strict_case
76 {
77 return false;
78 }
79 else if (i != no_elems || strict_case) // see !strict_case && thisType
80 {
81 // or strict_case and all true
82 return true;
83 }
84 else
85 {
86 return false;
87 }
88 }
89 else
90 {
91 return dynamic_cast<T>(obj) != NULL;
92 }
93 return true;
94}
95}
96#endif
#define COVISEEXPORT
Definition: coExport.h:200
#define NULL
Definition: covise_list.h:22
GLsizei GLsizei GLuint * obj
Definition: khronos-glext.h:6733
list of all chemical elements
Definition: coConfig.h:27
Definition: covise_objalg.h:28
static bool containsType(const coDistributedObject *obj, bool strict_case=true)
Definition: covise_objalg.h:43
Definition: coDistributedObject.h:296
Definition: coDoSet.h:51