blob: b062f9a8ad9514935f8384ea32f710812bff412e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
// -*- C++ -*-
//=============================================================================
/**
* @file Storable_File_Guard.h
*
* $Id$
*
* @author Rich Seibel (seibelr@ociweb.com)
* @author Byron Harris (harrisb@ociweb.com)
*/
//=============================================================================
#ifndef TAO_STORABLE_FILE_GUARD_H
#define TAO_STORABLE_FILE_GUARD_H
#include "tao/orbconf.h"
#include "tao/TAO_Export.h"
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
namespace TAO
{
class Storable_Base;
/**
* @class Storable_File_Guard
* @brief Bridge abstract class for TAO_Storable_Base that performs locking.
*
* A guard for Storable_Base that opens a file
* for read/write and sets a lock on it. It then checks if the file has
* changed and re-reads it if it has.
*
* The destructor releases the lock.
*/
class TAO_Export Storable_File_Guard
{
public:
Storable_File_Guard (bool redundant);
virtual ~Storable_File_Guard ();
/// Releases the lock, closes the file, and deletes the I/O stream.
void release (void);
/// Returns the stream to read/write on
Storable_Base & peer (void);
protected:
/// Should be called by constructors of derived classes
/// since can't call virtual functions below in constructor
/// of this class.
void init (const char * mode);
virtual void set_parent_last_changed (const time_t & time) = 0;
virtual time_t get_parent_last_changed () = 0;
virtual void create_child () = 0;
virtual bool is_child_created () = 0;
virtual Storable_Base * create_stream (const char * mode) = 0;
/// The pointer to the actual file I/O (bridge pattern)
Storable_Base *fl_;
private:
bool redundant_;
/// Default constructor
Storable_File_Guard ();
/// A flag to keep us from trying to close things more than once.
int closed_;
/// The flags that we were opened with
int rwflags_;
/// Symbolic values for the flags in the above
enum { mode_write = 1, mode_read = 2, mode_create = 4 };
};
}
TAO_END_VERSIONED_NAMESPACE_DECL
#endif
|