BALL 1.5.0
Loading...
Searching...
No Matches
factory.h
Go to the documentation of this file.
1// -*- Mode: C++; tab-width: 2; -*-
2// vi: set ts=2:
3//
4
5#ifndef BALL_CONCEPT_FACTORY_H
6#define BALL_CONCEPT_FACTORY_H
7
8#ifndef BALL_COMMON_H
9# include <BALL/common.h>
10#endif
11
12
13namespace BALL
14{
15
23 template <typename T>
24 class Factory
25 {
26 public:
27
29 static T* create() { return new T; }
30
32 static void* createVoid() { return (void*)new T; }
33
35 static const T& getDefault()
36 {
37 static T default_instance;
38 return default_instance;
39 }
40 };
41}
42
43#endif // BALL_CONCEPT_FACTORY_H
static T * create()
Return a pointer to a new instance of T.
Definition factory.h:29
static const T & getDefault()
Return a reference to a (pre-instantiated) default object.
Definition factory.h:35
static void * createVoid()
Return a void pointer to a new instance of T.
Definition factory.h:32