types.hpp

См. документацию.
00001 /*
00002 
00003 Copyright (c) 2002-2005, Yauheni Akhotnikau
00004 All rights reserved.
00005 
00006 Redistribution and use in source and binary forms, with or without
00007 modification, are permitted provided that the following conditions are met:
00008 
00009 - Redistributions of source code must retain the above copyright notice, this
00010 list of conditions and the following disclaimer.
00011 
00012 - Redistributions in binary form must reproduce the above copyright notice, this
00013 list of conditions and the following disclaimer in the documentation and/or
00014 other materials provided with the distribution.
00015 
00016 - The name of the author may not be used to endorse or promote products derived
00017 from this software without specific prior written permission.
00018 
00019 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
00020 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00021 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
00022 EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00024 OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00027 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
00028 OF SUCH DAMAGE.
00029 
00030 */
00031 
00038 #if !defined( _OESS_1__SCHEME__TYPES_HPP_ )
00039 #define _OESS_1__SCHEME__TYPES_HPP_
00040 
00041 #include <exception>
00042 #include <iterator>
00043 
00044 #include <oess_1/scheme/h/declspec.hpp>
00045 
00046 #include <string>
00047 
00048 #include <cpp_util_2/h/nocopy.hpp>
00049 
00050 #include <oess_1/defs/h/types.hpp>
00051 
00052 namespace oess_1 {
00053 
00054 namespace scheme {
00055 
00056 class type_t;
00057 
00058 //
00059 // base_t
00060 //
00061 
00065 class OESS_1__SCHEME__TYPE  base_t
00066 {
00067   public :
00068     virtual ~base_t();
00069 
00070     virtual const type_t &
00071     query_type() const = 0;
00072 
00074     virtual bool
00075     is_virtual() const = 0;
00076 
00078     /* \since v.1.2.0 */
00079     virtual bool
00080     is_extension_of() const = 0;
00081 };
00082 
00083 //
00084 // cpp_mapping_t
00085 //
00086 
00090 class OESS_1__SCHEME__TYPE  cpp_mapping_t {
00091   public :
00092     virtual ~cpp_mapping_t();
00093 
00095 
00098     virtual const std::string &
00099     query_name() const = 0;
00100 };
00101 
00102 //
00103 // attr_cont_kind_t
00104 //
00105 
00113 class OESS_1__SCHEME__TYPE  attr_cont_kind_t {
00114   public :
00115     virtual ~attr_cont_kind_t();
00116 
00118     virtual oess_1::int_t
00119     query_kind_id() const = 0;
00120 };
00121 
00122 //
00123 // attr_type_t
00124 //
00125 
00129 class OESS_1__SCHEME__TYPE  attr_type_t {
00130   public :
00131     virtual ~attr_type_t();
00132 
00134     virtual const type_t &
00135     query_type() const = 0;
00136 
00138     enum type_kind_t {
00140       e_value,
00142       e_ptr,
00144       e_extension
00145     };
00146 
00147     virtual type_kind_t
00148     query_type_kind() const = 0;
00149 
00151     virtual const attr_cont_kind_t &
00152     query_cont_kind() const = 0;
00153 };
00154 
00155 //
00156 // attr_present_if_t
00157 //
00158 
00164 class attr_present_if_t
00165 : private cpp_util_2::nocopy_t
00166 {
00167   public :
00168     virtual ~attr_present_if_t();
00169 
00171 
00174     virtual const std::string &
00175     cpp() const
00176     throw( std::exception ) = 0;
00177 
00179     virtual bool
00180     is_cpp() const = 0;
00181 };
00182 
00183 //
00184 // attr_default_t
00185 //
00186 
00191 class attr_default_t
00192 : private cpp_util_2::nocopy_t
00193 {
00194   public :
00195     virtual ~attr_default_t();
00196 
00198 
00201     virtual const std::string &
00202     cpp() const
00203     throw( std::exception ) = 0;
00204 
00206     virtual bool
00207     is_cpp() const = 0;
00208 
00210     virtual bool
00211     is_optional() const = 0;
00212 
00214 
00219     virtual const attr_present_if_t &
00220     present_if() const = 0;
00221 };
00222 
00223 //
00224 // attr_t
00225 //
00226 
00230 class OESS_1__SCHEME__TYPE  attr_t {
00231   public :
00232     virtual ~attr_t();
00233 
00235     virtual const std::string &
00236     query_name() const = 0;
00237 
00239     virtual const attr_type_t &
00240     query_attr_type() const = 0;
00241 
00247     virtual const attr_default_t *
00248     query_attr_default() const = 0;
00249 
00262     virtual unsigned int
00263     extension_level() const = 0;
00264 };
00265 
00266 //
00267 // type_t
00268 //
00269 
00273 class OESS_1__SCHEME__TYPE  type_t {
00274   public :
00275     virtual ~type_t();
00276 
00278     virtual const std::string &
00279     query_name() const = 0;
00280 
00282     virtual bool
00283     is_defined() const = 0;
00284 
00286     virtual bool
00287     is_builtin() const = 0;
00288 
00290     virtual bool
00291     is_abstract() const = 0;
00292 
00297     virtual bool
00298     is_extensible() const = 0;
00299 
00304     virtual bool
00305     is_subclassing_by_extension() const = 0;
00306 
00315     virtual bool
00316     is_derived_as_extension() const = 0;
00317 
00319     virtual size_t
00320     query_base_count() const = 0;
00321 
00323 
00324     virtual const base_t &
00325     query_base( size_t index ) const = 0;
00326 
00328 
00329     virtual const base_t *
00330     find_base( const std::string & name ) const = 0;
00331 
00333 
00336     virtual size_t
00337     query_attr_count() const = 0;
00338 
00340 
00347     virtual const attr_t &
00348     query_attr( size_t index ) const = 0;
00349 
00351 
00352     virtual const attr_t *
00353     find_attr( const std::string & name ) const = 0;
00354 
00356     virtual const cpp_mapping_t &
00357     query_cpp_mapping() const = 0;
00358 
00360 
00365     virtual unsigned int
00366     extension_deep() const = 0;
00367 
00369 
00373     virtual unsigned int
00374     extension_attr_count( unsigned int extension ) const = 0;
00375 
00377 
00382     virtual const attr_t &
00383     extension_attr( unsigned int extension,
00384       unsigned int attr_index ) const = 0;
00385 };
00386 
00387 //
00388 // pseudo_base_list_t
00389 //
00390 
00395 class pseudo_base_list_t {
00396   private :
00397     const type_t &  m_type;
00398 
00399   public :
00400     inline
00401     pseudo_base_list_t( const type_t & t ) :
00402       m_type( t )
00403     {
00404     }
00405 
00406     class const_iterator 
00407       : public std::iterator< std::forward_iterator_tag, base_t > {
00408       friend class pseudo_base_list_t;
00409       private :
00410         const type_t *  m_type;
00411         size_t  m_index;
00412 
00413         inline
00414         const_iterator(
00415           const type_t & t,
00416           size_t index ) :
00417           m_type( &t ),
00418           m_index( index )
00419         {
00420         }
00421 
00422       public :
00423         inline
00424         const_iterator() :
00425           m_type( 0 ),
00426           m_index( 0 )
00427         {
00428         }
00429 
00430         inline
00431         const_iterator(
00432           const const_iterator & o ) :
00433           m_type( o.m_type ),
00434           m_index( o.m_index )
00435         {
00436         }
00437 
00438         inline const base_t &
00439         operator*() const {
00440           return m_type->query_base( m_index );
00441         }
00442 
00443         bool
00444         operator==( const const_iterator & o ) const {
00445           return ( m_type == o.m_type && m_index == o.m_index );
00446         }
00447 
00448         bool
00449         operator!=( const const_iterator & o ) const {
00450           return ( m_type != o.m_type || m_index != o.m_index );
00451         }
00452 
00453         const_iterator&
00454         operator++() {
00455           ++m_index;
00456           return *this;
00457         }
00458 
00459         const_iterator
00460         operator++( int ) {
00461           return const_iterator( *m_type, m_index++ );
00462         }
00463     };
00464 
00465     inline const_iterator
00466     begin() const {
00467       return const_iterator( m_type, 0 );
00468     }
00469 
00470     inline const_iterator
00471     end() const {
00472       return const_iterator( m_type, m_type.query_base_count() );
00473     }
00474 };
00475 
00476 //
00477 // pseudo_attr_list_t
00478 //
00483 class pseudo_attr_list_t {
00484   private :
00486     const type_t &  m_type;
00487 
00488   public :
00490     inline
00491     pseudo_attr_list_t(
00494       const type_t & t )
00495       : m_type( t )
00496     {
00497     }
00498 
00500     class const_iterator
00501       : public std::iterator< std::forward_iterator_tag, attr_t > {
00502       friend class pseudo_attr_list_t;
00503       private :
00506 
00510         const type_t *  m_type;
00512         size_t  m_index;
00513 
00515 
00518         inline
00519         const_iterator(
00520           const type_t & t,
00521           size_t index ) :
00522           m_type( &t ),
00523           m_index( index )
00524         {
00525         }
00526 
00527       public :
00529         inline
00530         const_iterator() :
00531           m_type( 0 ),
00532           m_index( 0 )
00533         {
00534         }
00535 
00537         inline
00538         const_iterator(
00539           const const_iterator & o ) :
00540           m_type( o.m_type ),
00541           m_index( o.m_index )
00542         {
00543         }
00544 
00545         inline const attr_t &
00546         operator*() const {
00547           return m_type->query_attr( m_index );
00548         }
00549 
00550         bool
00551         operator==( const const_iterator & o ) const {
00552           return ( m_type == o.m_type && m_index == o.m_index );
00553         }
00554 
00555         bool
00556         operator!=( const const_iterator & o ) const {
00557           return ( m_type != o.m_type || m_index != o.m_index );
00558         }
00559 
00560         const_iterator&
00561         operator++() {
00562           ++m_index;
00563           return *this;
00564         }
00565 
00566         const_iterator
00567         operator++( int ) {
00568           return const_iterator( *m_type, m_index++ );
00569         }
00570     };
00571 
00573     inline const_iterator
00574     begin() const {
00575       return const_iterator( m_type, 0 );
00576     }
00577 
00580     inline const_iterator
00581     end() const {
00582       return const_iterator( m_type, m_type.query_attr_count() );
00583     }
00584 };
00585 
00586 //
00587 // pseudo_extension_attr_list_t
00588 //
00589 
00598 class pseudo_extension_attr_list_t {
00599   private :
00600     const type_t &  m_type;
00601     const unsigned int  m_extension;
00602 
00603   public :
00604     inline
00605     pseudo_extension_attr_list_t(
00606       const type_t & t,
00607       unsigned int extension )
00608     : m_type( t )
00609     , m_extension( extension )
00610     {}
00611 
00612     class const_iterator
00613       : public std::iterator< std::forward_iterator_tag, attr_t >
00614     {
00615       friend class pseudo_extension_attr_list_t;
00616       private :
00617         const type_t *  m_type;
00618         const unsigned int m_extension;
00619         size_t  m_index;
00620 
00621         inline
00622         const_iterator(
00623           const type_t & t,
00624           const unsigned int extension,
00625           size_t index )
00626         : m_type( &t )
00627         , m_extension( extension )
00628         , m_index( index )
00629         {}
00630 
00631       public :
00632         inline
00633         const_iterator()
00634         : m_type( 0 )
00635         , m_extension( 0 )
00636         , m_index( 0 )
00637         {}
00638 
00639         inline
00640         const_iterator(
00641           const const_iterator & o )
00642         : m_type( o.m_type )
00643         , m_extension( o.m_extension )
00644         , m_index( o.m_index )
00645         {}
00646 
00647         inline const attr_t &
00648         operator*() const
00649         {
00650           return m_type->extension_attr(
00651             m_extension, m_index );
00652         }
00653 
00654         bool
00655         operator==( const const_iterator & o ) const
00656         {
00657           return ( m_type == o.m_type &&
00658             m_extension == o.m_extension &&
00659             m_index == o.m_index );
00660         }
00661 
00662         bool
00663         operator!=( const const_iterator & o ) const
00664         {
00665           return ( m_type != o.m_type ||
00666             m_extension != o.m_extension ||
00667             m_index != o.m_index );
00668         }
00669 
00670         const_iterator&
00671         operator++()
00672         {
00673           ++m_index;
00674           return *this;
00675         }
00676 
00677         const_iterator
00678         operator++( int )
00679         {
00680           return const_iterator( *m_type,
00681             m_extension, m_index++ );
00682         }
00683     };
00684 
00685     inline const_iterator
00686     begin() const
00687     {
00688       return const_iterator( m_type, m_extension, 0 );
00689     }
00690 
00691     inline const_iterator
00692     end() const
00693     {
00694       return const_iterator( m_type, m_extension,
00695         m_type.extension_attr_count( m_extension ) );
00696     }
00697 };
00698 
00699 /*
00700   Описания итерфейсов для всех поддерживаемых разновидностей
00701   типов атрибутов.
00702 */
00703 
00704 //
00705 // single_obj_kind_t
00706 //
00707 
00712 class OESS_1__SCHEME__TYPE  single_obj_kind_t :
00713   public attr_cont_kind_t {
00714   public :
00715     virtual ~single_obj_kind_t();
00716 
00717     enum kind_id_t {
00719       e_id = 0
00720     };
00721 
00722     virtual oess_1::int_t
00723     query_kind_id() const;
00724 };
00725 
00726 //
00727 // stl_vector_kind_t
00728 //
00729 
00734 class OESS_1__SCHEME__TYPE  stl_vector_kind_t :
00735   public attr_cont_kind_t {
00736   public :
00737     virtual ~stl_vector_kind_t();
00738 
00739     enum kind_id_t {
00741       e_id = 1
00742     };
00743 
00744     virtual oess_1::int_t
00745     query_kind_id() const;
00746 };
00747 
00748 //
00749 // stl_list_kind_t
00750 //
00751 
00756 class OESS_1__SCHEME__TYPE  stl_list_kind_t :
00757   public attr_cont_kind_t {
00758   public :
00759     virtual ~stl_list_kind_t();
00760 
00761     enum kind_id_t {
00763       e_id = 2
00764     };
00765 
00766     virtual oess_1::int_t
00767     query_kind_id() const;
00768 };
00769 
00770 //
00771 // stl_deque_kind_t
00772 //
00773 
00778 class OESS_1__SCHEME__TYPE  stl_deque_kind_t :
00779   public attr_cont_kind_t {
00780   public :
00781     virtual ~stl_deque_kind_t();
00782 
00783     enum kind_id_t {
00785       e_id = 3
00786     };
00787 
00788     virtual oess_1::int_t
00789     query_kind_id() const;
00790 };
00791 
00792 //
00793 // stl_set_kind_t
00794 //
00795 
00800 class OESS_1__SCHEME__TYPE  stl_set_kind_t :
00801   public attr_cont_kind_t {
00802   public :
00803     virtual ~stl_set_kind_t();
00804 
00805     enum kind_id_t {
00807       e_id = 4
00808     };
00809 
00810     virtual oess_1::int_t
00811     query_kind_id() const;
00812 };
00813 
00814 //
00815 // stl_multiset_kind_t
00816 //
00817 
00822 class OESS_1__SCHEME__TYPE  stl_multiset_kind_t :
00823   public attr_cont_kind_t {
00824   public :
00825     virtual ~stl_multiset_kind_t();
00826 
00827     enum kind_id_t {
00829       e_id = 5
00830     };
00831 
00832     virtual oess_1::int_t
00833     query_kind_id() const;
00834 };
00835 
00836 //
00837 // stl_map_base_kind_t
00838 //
00839 
00844 class OESS_1__SCHEME__TYPE  stl_map_base_kind_t :
00845   public attr_cont_kind_t {
00846   public :
00847     virtual ~stl_map_base_kind_t();
00848 
00849     virtual oess_1::int_t
00850     query_kind_id() const = 0;
00851 
00853     virtual const type_t &
00854     query_key_type() const = 0;
00855 };
00856 
00857 //
00858 // stl_map_kind_t
00859 //
00860 
00865 class OESS_1__SCHEME__TYPE  stl_map_kind_t :
00866   public stl_map_base_kind_t {
00867   public :
00868     virtual ~stl_map_kind_t();
00869 
00870     enum kind_id_t {
00872       e_id = 6
00873     };
00874 
00875     virtual oess_1::int_t
00876     query_kind_id() const;
00877 
00878     virtual const type_t &
00879     query_key_type() const = 0;
00880 };
00881 
00882 //
00883 // stl_multimap_kind_t
00884 //
00885 
00890 class OESS_1__SCHEME__TYPE  stl_multimap_kind_t :
00891   public stl_map_base_kind_t {
00892   public :
00893     virtual ~stl_multimap_kind_t();
00894 
00895     enum kind_id_t {
00897       e_id = 7
00898     };
00899 
00900     virtual oess_1::int_t
00901     query_kind_id() const;
00902 
00903     // Тип ключа для map.
00904     // В качестве типа значения используется тип
00905     // атрибута.
00906     virtual const type_t &
00907     query_key_type() const = 0;
00908 };
00909 
00910 //
00911 // fixed_vector_kind_t
00912 //
00913 
00918 class OESS_1__SCHEME__TYPE  fixed_vector_kind_t :
00919   public attr_cont_kind_t {
00920   public :
00921     virtual ~fixed_vector_kind_t();
00922 
00923     enum kind_id_t {
00925       e_id = 8
00926     };
00927 
00928     virtual oess_1::int_t
00929     query_kind_id() const;
00930 
00931     // Размерность вектора в элементах.
00932     virtual size_t
00933     query_capacity() const = 0;
00934 };
00935 
00936 //
00937 // type_kind_processor_t
00938 //
00939 
00954 class OESS_1__SCHEME__TYPE  type_kind_processor_t {
00955   public :
00956     virtual ~type_kind_processor_t();
00957 
00959 
00961     void
00962     process_type_kind( const attr_type_t & k );
00963 
00964   protected :
00968     virtual void
00969     on_value_kind(
00970       const attr_type_t & k ) = 0;
00971 
00975     virtual void
00976     on_ptr_kind(
00977       const attr_type_t & k ) = 0;
00978 
00984     virtual void
00985     on_extension_kind(
00986       const attr_type_t & k ) = 0;
00987 };
00988 
00989 //
00990 // cont_kind_processor_t
00991 //
00992 
01008 class OESS_1__SCHEME__TYPE  cont_kind_processor_t {
01009   public :
01010     virtual ~cont_kind_processor_t();
01011 
01013 
01015     void
01016     process_cont_kind( const attr_cont_kind_t & k );
01017 
01018   protected :
01019     virtual void
01020     on_single_obj_kind(
01021       const single_obj_kind_t & k ) = 0;
01022 
01023     virtual void
01024     on_stl_vector_kind(
01025       const stl_vector_kind_t & k ) = 0;
01026 
01027     virtual void
01028     on_stl_list_kind(
01029       const stl_list_kind_t & k ) = 0;
01030 
01031     virtual void
01032     on_stl_deque_kind(
01033       const stl_deque_kind_t & k ) = 0;
01034 
01035     virtual void
01036     on_stl_set_kind(
01037       const stl_set_kind_t & k ) = 0;
01038 
01039     virtual void
01040     on_stl_multiset_kind(
01041       const stl_multiset_kind_t & k ) = 0;
01042 
01043     virtual void
01044     on_stl_map_kind(
01045       const stl_map_kind_t & k ) = 0;
01046 
01047     virtual void
01048     on_stl_multimap_kind(
01049       const stl_multimap_kind_t & k ) = 0;
01050 
01051     virtual void
01052     on_fixed_vector_kind(
01053       const fixed_vector_kind_t & k ) = 0;
01054 };
01055 
01056 } /* scheme */
01057 
01058 } /* namespace oess_1 */
01059 
01060 #endif
01061 

Документация по ObjESSty. Последние изменения: Fri Oct 13 18:35:36 2006. Создано системой  doxygen 1.4.7
Hosted by uCoz