ana/api/common.hpp

Go to the documentation of this file.
00001 /* $Id: common.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 
00003 /**
00004 * @file
00005 * @brief Main definitions for project ana.
00006 *
00007 * ana: Asynchronous Network API.
00008 * Copyright (C) 2010 - 2012 Guillermo Biset.
00009 *
00010 * This file is part of the ana project.
00011 *
00012 * System:         ana
00013 * Language:       C++
00014 *
00015 * Author:         Guillermo Biset
00016 * E-Mail:         billybiset AT gmail DOT com
00017 *
00018 * ana is free software: you can redistribute it and/or modify
00019 * it under the terms of the GNU General Public License as published by
00020 * the Free Software Foundation, either version 2 of the License, or
00021 * (at your option) any later version.
00022 *
00023 * ana is distributed in the hope that it will be useful,
00024 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00025 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00026 * GNU General Public License for more details.
00027 *
00028 * You should have received a copy of the GNU General Public License
00029 * along with ana.  If not, see <http://www.gnu.org/licenses/>.
00030 *
00031 */
00032 
00033 #ifndef ANA_COMMON_HPP
00034 #define ANA_COMMON_HPP
00035 
00036 #include <boost/asio/detail/socket_ops.hpp>
00037 #include <boost/cstdint.hpp>
00038 #include <boost/system/error_code.hpp>
00039 
00040 #include "../../global.hpp"
00041 
00042 namespace ana
00043 {
00044     /** @name Type and constant definitions
00045      *
00046      * Definitions of main types and relevant constants.
00047      */
00048     //@{
00049         /** Standard unsigned int, with fixed size to 32 bits.  */
00050         typedef boost::uint32_t ana_uint32 ;
00051 
00052         /** Standard int, with fixed size to 32 bits.           */
00053         typedef boost::int32_t  ana_int32  ;
00054 
00055         /** Standard unsigned int, with fixed size to 16 bits.  */
00056         typedef boost::uint16_t ana_uint16 ;
00057 
00058         /** Standard int, with fixed size to 16 bits.           */
00059         typedef boost::int16_t  ana_int16  ;
00060 
00061         /** Message size type.                                  */
00062         typedef ana_uint32  message_size   ;
00063 
00064         /** IDs of connected components, unique, non zero.      */
00065         typedef size_t      net_id         ;
00066 
00067         /** IDs of network operations, unique, zero = no-op.    */
00068         typedef size_t      operation_id   ;
00069 
00070         /** Port type, a std::string (instead of a short.)      */
00071         typedef std::string port           ;
00072 
00073         /** Address type, a string. Either IP of hostname.      */
00074         typedef std::string address        ;
00075 
00076         /** Send operation type, true to copy the buffer.       */
00077         typedef bool        send_type      ;
00078 
00079         /** Standard error code, can evaluate to bool.          */
00080         typedef boost::system::error_code error_code ;
00081 
00082         /** The default timeout error. */
00083         const ana::error_code operation_aborted =
00084                     boost::asio::error::make_error_code( boost::asio::error::operation_aborted );
00085 
00086         /** The default timeout error. */
00087         const ana::error_code timeout_error =
00088                     boost::asio::error::make_error_code( boost::asio::error::timed_out );
00089 
00090         /** A generic error. Used to describe an undefined error. */
00091         const ana::error_code generic_error =
00092                     boost::asio::error::make_error_code( boost::asio::error::fault );
00093 
00094         /** A network operation that didn't do anything.        */
00095         const operation_id no_operation = 0;
00096 
00097         /** An invalid net_id. Useful for error checking.       */
00098         const operation_id invalid_net_id = 0;
00099 
00100 
00101         /** Don't copy the buffer. */
00102         const send_type ZERO_COPY   = false;
00103 
00104         /** Copy the buffer.       */
00105         const send_type COPY_BUFFER = true ;
00106 
00107         /** Length of message header, 4 bytes.    */
00108         const message_size HEADER_LENGTH = sizeof(ana_uint32);
00109 
00110         /** Initial length of raw message buffer. */
00111         const message_size INITIAL_RAW_MODE_BUFFER_SIZE = 256 ;
00112     //@}
00113 }
00114 
00115 #endif
00116 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:02:31 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs