ALBA
albaPipeFactory.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaPipeFactory
5 Authors: Marco Petrone
6
7 Copyright (c) BIC
8 All rights reserved. See Copyright.txt or
9
10
11 This software is distributed WITHOUT ANY WARRANTY; without even
12 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 PURPOSE. See the above copyright notice for more information.
14
15=========================================================================*/
16#ifndef __albaPipeFactory_h
17#define __albaPipeFactory_h
18//----------------------------------------------------------------------------
19// includes :
20//----------------------------------------------------------------------------
21#include "albaObjectFactory.h"
22
24#define albaPlugPipeMacro(pipe_type,descr) \
25 RegisterNewPipe(pipe_type::GetStaticTypeName(), descr, pipe_type::NewObject);
26
27
28//----------------------------------------------------------------------------
29// forward declarations :
30//----------------------------------------------------------------------------
31class albaPipe;
32
33#ifdef ALBA_EXPORTS
34#include "albaDllMacros.h"
35EXPORT_STL_VECTOR(ALBA_EXPORT,std::string);
36#endif
37
43class ALBA_EXPORT albaPipeFactory : public albaObjectFactory
44{
45public:
47 virtual const char* GetALBASourceVersion() const;
48 virtual const char* GetDescription() const;
49
50 /* Initialize the factory creating and registering a new instance */
51 static int Initialize();
53 static albaPipeFactory *GetInstance();// {if (!m_Instance) Initialize(); return m_Instance;}
54
56 static albaPipe *CreatePipeInstance(const char *type_name);
57
60 void RegisterNewPipe(const char* pipe_name, const char* description, albaCreateObjectFunction createFunction);
61
63 static std::vector<std::string> &GetPipeNames();// {return m_PipeNames;}
64
65protected:
68
69 // static albaPipeFactory *m_Instance;
70 static bool m_Initialized;
71 // static std::vector<std::string> m_PipeNames;
72
73private:
74 albaPipeFactory(const albaPipeFactory&); // Not implemented.
75 void operator=(const albaPipeFactory&); // Not implemented.
76};
77
79template <class T>
81{
82 public:
83 albaPlugPipe(const char *description);
84
85};
86
87//------------------------------------------------------------------------------
89template <class T>
90albaPlugPipe<T>::albaPlugPipe(const char *description)
91//------------------------------------------------------------------------------
92{
94 if (factory)
95 {
96 factory->RegisterNewPipe(T::GetStaticTypeName(), description, T::NewObject);
97 }
98}
99
100#endif
#define EXPORT_STL_VECTOR(declspec_, T_)
Definition: albaDllMacros.h:84
albaObject *(* albaCreateObjectFunction)()
Create instances of classes using an object factory.
Object factory for Pipes.
void RegisterNewPipe(const char *pipe_name, const char *description, albaCreateObjectFunction createFunction)
This function can be used by Application code to register new Objects's to the mflCoreFactory.
albaTypeMacro(albaPipeFactory, albaObjectFactory)
virtual const char * GetALBASourceVersion() const
All sub-classes of albaObjectFactory should must return the version of ALBA they were built with.
static std::vector< std::string > & GetPipeNames()
return list of names for pipes plugged into this factory
virtual const char * GetDescription() const
Return a descriptive string describing the factory.
static int Initialize()
static albaPipeFactory * GetInstance()
return the instance pointer of the factory.
static albaPipe * CreatePipeInstance(const char *type_name)
create an instance of the pipe give its type name
static bool m_Initialized
Plug a pipe in the main ALBA Pipe factory.
albaPlugPipe(const char *description)
Plug a new Pipe class into the Pipe factory.