COVISE Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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"
22 #include <do/coDistributedObject.h>
23 
24 namespace covise
25 {
26 
28 {
29 public:
36  template <class T>
37  static bool containsType(const coDistributedObject *obj,
38  bool strict_case = true);
39 };
40 
41 template <class T>
42 bool
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
GLsizei GLsizei GLuint * obj
Definition: khronos-glext.h:6733
#define COVISEEXPORT
Definition: coExport.h:176
Definition: covise_objalg.h:27
#define NULL
Definition: covise_list.h:22
Definition: coDoSet.h:50
Definition: coDistributedObject.h:295
static bool containsType(const coDistributedObject *obj, bool strict_case=true)
Definition: covise_objalg.h:43