summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Log/Hash_LogStore.h
blob: 7c43c34a8a79edabc7bf9b25dcce12b1f448127c (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// -*- C++ -*-

//=============================================================================
/**
 *  @file   Hash_LogStore.h
 *
 *  $Id$
 *
 *  @author Matthew Braun <mjb2@cs.wustl.edu>
 *  @author Pradeep Gore <pradeep@cs.wustl.edu>
 *  @author David A. Hanvey <d.hanvey@qub.ac.uk>
 */
//=============================================================================

#ifndef TAO_TLS_HASH_LOGSTORE_H
#define TAO_TLS_HASH_LOGSTORE_H

#include /**/ "ace/pre.h"
#include /**/ "ace/config-all.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
#pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "orbsvcs/Log/LogStore.h"
#include "ace/Hash_Map_Manager.h"
#include "ace/Synch_Traits.h"
#include "ace/Null_Mutex.h"
#include "ace/RW_Thread_Mutex.h"
#include "orbsvcs/Log/log_serv_export.h"

ACE_BEGIN_VERSIONED_NAMESPACE_DECL
class ACE_Reactor;
ACE_END_VERSIONED_NAMESPACE_DECL

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

class TAO_LogMgr_i;
class TAO_Hash_LogRecordStore;

class TAO_Log_Serv_Export TAO_Hash_LogStore
  : public TAO_LogStore
{
public:
  // = Initialization and Termination Methods

  /// Constructor.
  TAO_Hash_LogStore (TAO_LogMgr_i* mgr);

  /// Destructor.
  virtual ~TAO_Hash_LogStore ();


  /// Lists all logs created by the log factory.
  virtual DsLogAdmin::LogList *
    list_logs (ACE_ENV_SINGLE_ARG_DECL)
    ACE_THROW_SPEC ((
                     CORBA::SystemException
                     ));

  /// Lists all log ids.
  virtual DsLogAdmin::LogIdList *
    list_logs_by_id (ACE_ENV_SINGLE_ARG_DECL)
    ACE_THROW_SPEC ((
                     CORBA::SystemException
                     ));

  /// Returns a reference to the log with the supplied id.
  virtual DsLogAdmin::Log_ptr
    find_log (DsLogAdmin::LogId id
              ACE_ENV_ARG_DECL)
    ACE_THROW_SPEC ((
                     CORBA::SystemException
                     ));

  /// Returns true if log exists, otherwise false
  virtual bool exists (DsLogAdmin::LogId id ACE_ENV_ARG_DECL);

  /// Remove the given entry from the hash table.
  virtual int remove (DsLogAdmin::LogId id ACE_ENV_ARG_DECL);

  /// @brief Create log
  virtual void
    create (DsLogAdmin::LogFullActionType full_action,
            CORBA::ULongLong max_size,
            const DsLogAdmin::CapacityAlarmThresholdList* thresholds,
            DsLogAdmin::LogId_out id_out
            ACE_ENV_ARG_DECL);

  /// @brief Create log
  virtual void
    create_with_id (DsLogAdmin::LogId id,
                    DsLogAdmin::LogFullActionType full_action,
                    CORBA::ULongLong max_size,
                    const DsLogAdmin::CapacityAlarmThresholdList* thresholds
                    ACE_ENV_ARG_DECL);

  /// @brief Get log record store
  ///
  /// Get/Create a log record store for log channel @a id.
  ///
  /// @param id log id
  ///
  virtual TAO_LogRecordStore*
    get_log_record_store (DsLogAdmin::LogId id
                          ACE_ENV_ARG_DECL);

private:
  ACE_SYNCH_RW_MUTEX	lock_;

  /// Define the HASHMAP.
  typedef ACE_Hash_Map_Manager <DsLogAdmin::LogId,
                                TAO_Hash_LogRecordStore*,
                                ACE_Null_Mutex> HASHMAP;

  /// The map of Logs created.
  HASHMAP hash_map_;

  /// The next log id to be assigned (if it hasn't already been
  /// taken by create_with_id().
  DsLogAdmin::LogId     next_id_;

  TAO_LogMgr_i*         logmgr_i_;
};

TAO_END_VERSIONED_NAMESPACE_DECL

#include /**/ "ace/post.h"

#endif /* TAO_TLS_HASH_LOGSTORE_H */