blob: 8c76dbc99a3db376e0aa75c5a2966e4ece21ba20 (
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
94
95
|
// -*- C++ -*-
//=============================================================================
/**
* @file Flat_File_Persistence.h
*
* $Id$
*
* @author Marina Spivak <marina@cs.wustl.edu>
*/
//=============================================================================
#ifndef TAO_FLAT_FILE_PERSISTENCE_H
#define TAO_FLAT_FILE_PERSISTENCE_H
#include "orbsvcs/Naming/Storable.h"
#include "ace/OS_NS_stdio.h"
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
//------------------------------------------------------------------------
// The Flat File concrete classes
//------------------------------------------------------------------------
class TAO_NS_FlatFileStream : public TAO_Storable_Base
{
public:
TAO_NS_FlatFileStream(const ACE_CString & file, const char * mode);
virtual ~TAO_NS_FlatFileStream();
/// Remove a file by name (file is not open)
virtual void remove();
/// Check if a file exists on disk (file is not open)
virtual int exists();
/// Open a file (the remaining methods below all require an open file)
virtual int open();
/// Close an open file
virtual int close();
/// Acquire a file lock
virtual int flock (int whence, int start, int len);
/// Release a file lock
virtual int funlock (int whence, int start, int len);
/// Returns the last time an open file was changed
virtual time_t last_changed(void);
/// Write a header to disk
virtual TAO_Storable_Base& operator << (
const TAO_NS_Persistence_Header& header);
/// Read a header from disk
virtual TAO_Storable_Base& operator >> (
TAO_NS_Persistence_Header& header);
/// Write a record to disk
virtual TAO_Storable_Base& operator << (
const TAO_NS_Persistence_Record& record);
/// Read a record from disk
virtual TAO_Storable_Base& operator >> (
TAO_NS_Persistence_Record& record);
/// Write the global data to disk
virtual TAO_Storable_Base& operator << (
const TAO_NS_Persistence_Global& global);
/// Read the global data from disk
virtual TAO_Storable_Base& operator >> (
TAO_NS_Persistence_Global& global);
private:
ACE_OS::ace_flock_t filelock_;
FILE* fl_;
ACE_CString file_;
ACE_CString mode_;
};
class TAO_NS_FlatFileFactory : public TAO_Naming_Service_Persistence_Factory
{
public:
// Factory Methods
/// Create the stream that can operate on a disk file
virtual TAO_Storable_Base *create_stream(const ACE_CString & file,
const ACE_TCHAR * mode);
};
TAO_END_VERSIONED_NAMESPACE_DECL
#endif
|