• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

GlobalPlugin.h

Go to the documentation of this file.
00001 /**
00002   Licensed to the Apache Software Foundation (ASF) under one
00003   or more contributor license agreements.  See the NOTICE file
00004   distributed with this work for additional information
00005   regarding copyright ownership.  The ASF licenses this file
00006   to you under the Apache License, Version 2.0 (the
00007   "License"); you may not use this file except in compliance
00008   with the License.  You may obtain a copy of the License at
00009 
00010       http://www.apache.org/licenses/LICENSE-2.0
00011 
00012   Unless required by applicable law or agreed to in writing, software
00013   distributed under the License is distributed on an "AS IS" BASIS,
00014   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015   See the License for the specific language governing permissions and
00016   limitations under the License.
00017  */
00018 
00019 /**
00020  * @file GlobalPlugin.h
00021  * @brief Contains the interface used in creating Global plugins.
00022  */
00023 
00024 #pragma once
00025 #ifndef ATSCPPAPI_GLOBALPLUGIN_H_
00026 #define ATSCPPAPI_GLOBALPLUGIN_H_
00027 
00028 #include <atscppapi/Plugin.h>
00029 
00030 namespace atscppapi {
00031 
00032 struct GlobalPluginState;
00033 
00034 /**
00035  * @brief The interface used when creating a GlobalPlugin.
00036  *
00037  * A GlobalPlugin is a Plugin that will fire for a given hook on all Transactions.
00038  * In otherwords, a GlobalPlugin is not tied to a specific plugin, a Transaction
00039  * specific plugin would be a TransactionPlugin.
00040  *
00041  * Depending on the
00042  * type of hook you choose to build you will implement one or more callback methods.
00043  * Here is a simple example of a GlobalPlugin:
00044  *
00045  * \code
00046  * class GlobalHookPlugin : public GlobalPlugin {
00047  * public:
00048  *  GlobalHookPlugin() {
00049  *   registerHook(HOOK_READ_REQUEST_HEADERS_PRE_REMAP);
00050  *  }
00051  *  virtual void handleReadRequestHeadersPreRemap(Transaction &transaction) {
00052  *    std::cout << "Hello from handleReadRequesHeadersPreRemap!" << std::endl;
00053  *    transaction.resume();
00054  *  }
00055  * };
00056  * \endcode
00057  * @see Plugin
00058  */
00059 class GlobalPlugin : public Plugin {
00060 public:
00061   /**
00062    * registerHook is the mechanism used to attach a global hook.
00063    *
00064    * \note Whenever you register a hook you must have the appropriate callback definied in your GlobalPlugin
00065    *  see HookType and Plugin for the correspond HookTypes and callback methods. If you fail to implement the
00066    *  callback, a default implmentation will be used that will only resume the Transaction.
00067    *
00068    * @param HookType the type of hook you wish to register
00069    * @see HookType
00070    * @see Plugin
00071    */
00072   void registerHook(Plugin::HookType);
00073   virtual ~GlobalPlugin();
00074 protected:
00075   /**
00076    * Constructor.
00077    *
00078    * @param ignore_internal_transactions When true, all hooks registered by this plugin are ignored
00079    *                                     for internal transactions (internal transactions are created
00080    *                                     when other plugins create requests). Defaults to false.
00081    */
00082   GlobalPlugin(bool ignore_internal_transactions = false);
00083 private:
00084   GlobalPluginState *state_; /**< Internal state tied to a GlobalPlugin */
00085 };
00086 
00087 } /* atscppapi */
00088 
00089 
00090 #endif /* ATSCPPAPI_GLOBALPLUGIN_H_ */

Generated by  doxygen 1.7.1