source: pacpusframework/trunk/3rd/apache-log4cxx/include/log4cxx/helpers/cyclicbuffer.h@ 184

Last change on this file since 184 was 89, checked in by morasjul, 12 years ago

PACPUS 2.0 Beta deployed in new branch

Major changes:
-Add communication interface between components
-Add examples for communications interface (TestComponents)
-Move to Qt5 support

  • Property svn:executable set to *
File size: 3.8 KB
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef _LOG4CXX_HELPERS_CYCLICBUFFER_H
19#define _LOG4CXX_HELPERS_CYCLICBUFFER_H
20
21#include <log4cxx/spi/loggingevent.h>
22
23namespace log4cxx
24{
25 namespace helpers
26 {
27 /**
28 CyclicBuffer is used by other appenders to hold instances of
29 {@link log4cxx::spi::LoggingEvent LoggingEvent} for immediate
30 or deferred display.
31 <p>This buffer gives read access to any element in the buffer not
32 just the first or last element.
33 */
34 class LOG4CXX_EXPORT CyclicBuffer
35 {
36 log4cxx::spi::LoggingEventList ea;
37 int first;
38 int last;
39 int numElems;
40 int maxSize;
41
42 public:
43 /**
44 Instantiate a new CyclicBuffer of at most <code>maxSize</code>
45 events.
46 The <code>maxSize</code> argument must a positive integer.
47 @param maxSize The maximum number of elements in the buffer.
48 @throws IllegalArgumentException if <code>maxSize</code>
49 is negative.
50 */
51 CyclicBuffer(int maxSize);
52 ~CyclicBuffer();
53
54 /**
55 Add an <code>event</code> as the last event in the buffer.
56 */
57 void add(const spi::LoggingEventPtr& event);
58
59 /**
60 Get the <i>i</i>th oldest event currently in the buffer. If
61 <em>i</em> is outside the range 0 to the number of elements
62 currently in the buffer, then <code>null</code> is returned.
63 */
64 spi::LoggingEventPtr get(int i);
65
66 int getMaxSize() const
67 { return maxSize; }
68
69 /**
70 Get the oldest (first) element in the buffer. The oldest element
71 is removed from the buffer.
72 */
73 spi::LoggingEventPtr get();
74
75 /**
76 Get the number of elements in the buffer. This number is
77 guaranteed to be in the range 0 to <code>maxSize</code>
78 (inclusive).
79 */
80 int length() const
81 { return numElems; }
82
83 /**
84 Resize the cyclic buffer to <code>newSize</code>.
85 @throws IllegalArgumentException if <code>newSize</code> is negative.
86 */
87 void resize(int newSize);
88 }; // class CyclicBuffer
89 } //namespace helpers
90} //namespace log4cxx
91
92#endif //_LOG4CXX_HELPERS_CYCLICBUFFER_H
Note: See TracBrowser for help on using the repository browser.