activemq-cpp-3.3.0

src/main/activemq/core/policies/DefaultPrefetchPolicy.h

Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef _ACTIVEMQ_CORE_POLICIES_DEFAULTPREFETCHPOLICY_H_
00019 #define _ACTIVEMQ_CORE_POLICIES_DEFAULTPREFETCHPOLICY_H_
00020 
00021 #include <activemq/util/Config.h>
00022 
00023 #include <activemq/core/PrefetchPolicy.h>
00024 
00025 namespace activemq {
00026 namespace core {
00027 namespace policies {
00028 
00029     class AMQCPP_API DefaultPrefetchPolicy : public PrefetchPolicy {
00030     private:
00031 
00032         int durableTopicPrefetch;
00033         int queuePrefetch;
00034         int queueBrowserPrefetch;
00035         int topicPrefetch;
00036 
00037     public:
00038 
00039         static int MAX_PREFETCH_SIZE;
00040         static int DEFAULT_DURABLE_TOPIC_PREFETCH;
00041         static int DEFAULT_QUEUE_PREFETCH;
00042         static int DEFAULT_QUEUE_BROWSER_PREFETCH;
00043         static int DEFAULT_TOPIC_PREFETCH;
00044 
00045     private:
00046 
00047         DefaultPrefetchPolicy( const DefaultPrefetchPolicy& );
00048         DefaultPrefetchPolicy& operator= ( DefaultPrefetchPolicy& );
00049 
00050     public:
00051 
00052         DefaultPrefetchPolicy();
00053 
00054         virtual ~DefaultPrefetchPolicy();
00055 
00056         virtual void setDurableTopicPrefetch( int value ) {
00057             this->durableTopicPrefetch = getMaxPrefetchLimit( value );
00058         }
00059 
00060         virtual int getDurableTopicPrefetch() const {
00061             return this->durableTopicPrefetch;
00062         }
00063 
00064         virtual void setQueuePrefetch( int value ) {
00065             this->queuePrefetch = getMaxPrefetchLimit( value );
00066         }
00067 
00068         virtual int getQueuePrefetch() const {
00069             return this->queuePrefetch;
00070         }
00071 
00072         virtual void setQueueBrowserPrefetch( int value ) {
00073             this->queueBrowserPrefetch = getMaxPrefetchLimit( value );
00074         }
00075 
00076         virtual int getQueueBrowserPrefetch() const {
00077             return this->queueBrowserPrefetch;
00078         }
00079 
00080         virtual void setTopicPrefetch( int value ) {
00081             this->topicPrefetch = getMaxPrefetchLimit( value );
00082         }
00083 
00084         virtual int getTopicPrefetch() const {
00085             return this->topicPrefetch;
00086         }
00087 
00088         virtual int getMaxPrefetchLimit( int value ) const {
00089             return value < MAX_PREFETCH_SIZE ? value : MAX_PREFETCH_SIZE;
00090         }
00091 
00092         virtual PrefetchPolicy* clone() const;
00093 
00094     };
00095 
00096 }}}
00097 
00098 #endif /* _ACTIVEMQ_CORE_POLICIES_DEFAULTPREFETCHPOLICY_H_ */