cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cmnClassServicesBase.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
4 /*
5 
6  Author(s): Anton Deguet, Peter Kazanzides
7  Created on: 2004-08-18
8 
9  (C) Copyright 2004-2012 Johns Hopkins University (JHU), All Rights
10  Reserved.
11 
12 --- begin cisst license - do not edit ---
13 
14 This software is provided "as is" under an open source license, with
15 no warranty. The complete license can be found in license.txt and
16 http://www.cisst.org/cisst/license.txt.
17 
18 --- end cisst license ---
19 
20 */
21 
22 
27 #pragma once
28 
29 #ifndef _cmnClassServicesBase_h
30 #define _cmnClassServicesBase_h
31 
33 #include <cisstCommon/cmnLogLoD.h>
34 
35 #include <string>
36 #include <typeinfo>
37 
38 #include <cisstCommon/cmnExport.h>
39 
46 {
47  public:
51 
59  cmnClassServicesBase(const std::string & className,
60  const std::type_info * typeInfo,
61  const cmnClassServicesBase * parentServices,
62  const std::string & libraryName,
64 
65 
67  virtual ~cmnClassServicesBase() {}
68 
69 
80  virtual cmnGenericObject * Create(void) const = 0;
81 
99  virtual cmnGenericObject * Create(const cmnGenericObject & other) const = 0;
100 
102  virtual cmnGenericObject * CreateWithArg(const cmnGenericObject & arg) const = 0;
103 
105  virtual bool Create(cmnGenericObject * existing, const cmnGenericObject & other) const = 0;
106 
118  virtual cmnGenericObject * CreateArray(size_t size) const = 0;
119 
121  virtual cmnGenericObject * CreateArray(size_t size,
122  const cmnGenericObject & other) const = 0;
123 
124  virtual bool DeleteArray(generic_pointer & data, size_t & size) const = 0;
125 
127  virtual bool Delete(cmnGenericObject * existing) const = 0;
128 
130  virtual size_t GetSize(void) const = 0;
131 
133  virtual bool HasDynamicCreation(void) const = 0;
134 
136  virtual bool DefaultConstructorAvailable(void) const = 0;
137  virtual bool CopyConstructorAvailable(void) const = 0;
138  virtual bool OneArgConstructorAvailable(void) const = 0;
139 
142  virtual const cmnClassServicesBase *GetConstructorArgServices(void) const = 0;
143 
148  const std::string & GetName(void) const;
149 
155  const std::type_info * TypeInfoPointer(void) const;
156 
162  const cmnLogMask & GetLogMask(void) const;
163 
164  inline const cmnLogMask & GetLoD(void) const {
165  return GetLogMask();
166  }
167 
168 
173  void SetLogMask(cmnLogMask mask);
174 
175  inline void CISST_DEPRECATED SetLoD(cmnLogMask mask) {
176  SetLogMask(mask);
177  }
178 
180  return ParentServices;
181  }
182 
183  bool IsDerivedFrom(const cmnClassServicesBase *parentServices) const;
184 
185  template <class _Parent>
186  bool IsDerivedFrom(void) const {
187  return IsDerivedFrom(_Parent::ClassServices());
188  }
189 
191  const std::string & GetLibraryName(void) const;
192 
193 private:
195  const std::string * NameMember;
196 
197  const std::type_info * TypeInfoMember;
198 
200  const cmnClassServicesBase * ParentServices;
201 
205  const std::string LibraryName;
206 
208  cmnLogMask LogMask;
209 };
210 
211 
212 
223 template <class _class>
225 
226 
227 #endif // _cmnClassServicesBase_h
228 
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
cmnClassServicesBase * cmnClassServicesInstantiate(void)
#define CISST_DEPRECATED
Definition: cmnPortability.h:310
const cmnLogMask & GetLoD(void) const
Definition: cmnClassServicesBase.h:164
bool IsDerivedFrom(void) const
Definition: cmnClassServicesBase.h:186
cmnGenericObject * generic_pointer
Definition: cmnClassServicesBase.h:50
Declaration of Levels of Detail for cmnLogger (human readable logging)
Base class for high level objects.
Definition: cmnGenericObject.h:51
Macros to export the symbols of cisstCommon (in a Dll).
virtual ~cmnClassServicesBase()
Definition: cmnClassServicesBase.h:67
void CISST_DEPRECATED SetLoD(cmnLogMask mask)
Definition: cmnClassServicesBase.h:175
short cmnLogMask
Definition: cmnLogLoD.h:67
Base class for class services.
Definition: cmnClassServicesBase.h:45
const cmnClassServicesBase * GetParentServices(void) const
Definition: cmnClassServicesBase.h:179
#define CMN_LOG_ALLOW_DEFAULT
Definition: cmnLogLoD.h:76