Safir SDK Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StartupSynchronizer.h
Go to the documentation of this file.
1 /******************************************************************************
2 *
3 * Copyright Saab AB, 2007-2013 (http://safir.sourceforge.net)
4 *
5 * Created by: Lars Hagström / stlrha
6 *
7 *******************************************************************************
8 *
9 * This file is part of Safir SDK Core.
10 *
11 * Safir SDK Core is free software: you can redistribute it and/or modify
12 * it under the terms of version 3 of the GNU General Public License as
13 * published by the Free Software Foundation.
14 *
15 * Safir SDK Core is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with Safir SDK Core. If not, see <http://www.gnu.org/licenses/>.
22 *
23 ******************************************************************************/
24 #ifndef __LLUF_STARTUP_SYNCHRONIZER_H__
25 #define __LLUF_STARTUP_SYNCHRONIZER_H__
26 
27 #include <Safir/Utilities/Internal/VisibilityHelpers.h>
28 
29 #ifdef lluf_startup_synchronizer_EXPORTS
30 # define LLUF_STARTUP_SYNCHRONIZER_API SAFIR_HELPER_DLL_EXPORT
31 #else
32 # define LLUF_STARTUP_SYNCHRONIZER_API SAFIR_HELPER_DLL_IMPORT
33 # define SAFIR_LIBRARY_NAME "lluf_startup_synchronizer"
34 # define SAFIR_NO_DEBUG_LIBRARY_SUFFIX
35 # include <Safir/Utilities/Internal/AutoLink.h>
36 #endif
37 #define LLUF_STARTUP_SYNCHRONIZER_LOCAL SAFIR_HELPER_DLL_LOCAL
38 
39 #include <boost/noncopyable.hpp>
40 #include <boost/shared_ptr.hpp>
41 
42 
43 #ifdef _MSC_VER
44 #pragma warning (push)
45 #pragma warning (disable: 4275)
46 #endif
47 
48 
49 namespace Safir
50 {
51 namespace Utilities
52 {
54  class StartupSynchronizerImpl;
55 
56 
63  {
64  public:
65  virtual ~Synchronized() {}
66 
77  virtual void Create() = 0;
78 
83  virtual void Use() = 0;
84 
94  virtual void Destroy() = 0;
95  };
96 
111  private boost::noncopyable
112  {
113  public:
117  explicit StartupSynchronizer(const char* uniqueName);
118 
127 
139  void Start(Synchronized* const synchronized);
140 
141  private:
142 
143 #ifdef _MSC_VER
144 #pragma warning (push)
145 #pragma warning (disable: 4251)
146 #endif
147 
148  boost::shared_ptr<StartupSynchronizerImpl> m_impl;
149 
150 #ifdef _MSC_VER
151 #pragma warning (pop)
152 #endif
153 
154  Synchronized* m_synchronized;
155 
156  };
157 
158 }
159 }
160 
161 
162 #ifdef _MSC_VER
163 #pragma warning (pop)
164 #endif
165 
166 
167 #endif
168 
virtual void Use()=0
All processes will get a call to Use, even the one that got the Create callback.
virtual ~Synchronized()
Definition: StartupSynchronizer.h:65
This class can be used to synchronize creation and opening of a resource that is shared between multi...
Definition: StartupSynchronizer.h:110
#define LLUF_STARTUP_SYNCHRONIZER_API
Definition: StartupSynchronizer.h:32
virtual void Create()=0
Guarantees are that only one call to Create in all processes will be made.
virtual void Destroy()=0
This callback will be called when the last process destroys its StartupSynchronizer.
Interface for a synchronized object.
Definition: StartupSynchronizer.h:62