serialasn.hpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:6k
源码类别:

生物技术

开发平台:

C/C++

  1. /*
  2.  * ===========================================================================
  3.  * PRODUCTION $Log: serialasn.hpp,v $
  4.  * PRODUCTION Revision 1000.0  2003/10/29 17:29:46  gouriano
  5.  * PRODUCTION PRODUCTION: IMPORTED [ORIGINAL] Dev-tree R1.15
  6.  * PRODUCTION
  7.  * ===========================================================================
  8.  */
  9. #ifndef SERIALASN__HPP
  10. #define SERIALASN__HPP
  11. /*  $Id: serialasn.hpp,v 1000.0 2003/10/29 17:29:46 gouriano Exp $
  12. * ===========================================================================
  13. *
  14. *                            PUBLIC DOMAIN NOTICE
  15. *               National Center for Biotechnology Information
  16. *
  17. *  This software/database is a "United States Government Work" under the
  18. *  terms of the United States Copyright Act.  It was written as part of
  19. *  the author's official duties as a United States Government employee and
  20. *  thus cannot be copyrighted.  This software/database is freely available
  21. *  to the public for use. The National Library of Medicine and the U.S.
  22. *  Government have not placed any restriction on its use or reproduction.
  23. *
  24. *  Although all reasonable efforts have been taken to ensure the accuracy
  25. *  and reliability of the software and data, the NLM and the U.S.
  26. *  Government do not and cannot warrant the performance or results that
  27. *  may be obtained by using this software or data. The NLM and the U.S.
  28. *  Government disclaim all warranties, express or implied, including
  29. *  warranties of performance, merchantability or fitness for any particular
  30. *  purpose.
  31. *
  32. *  Please cite the author in any work or product based on this material.
  33. *
  34. * ===========================================================================
  35. *
  36. * Author: Eugene Vasilchenko
  37. *
  38. * File Description:
  39. *   File to be included in modules implementing GetTypeInfo methods.
  40. *
  41. */
  42. #include <corelib/ncbistd.hpp>
  43. #if HAVE_NCBI_C
  44. #include <serial/serialimpl.hpp>
  45. #include <serial/serialasndef.hpp>
  46. /** @addtogroup TypeInfoC
  47.  *
  48.  * @{
  49.  */
  50. BEGIN_NCBI_SCOPE
  51. // ASN
  52. inline
  53. CTypeRef GetOctetStringTypeRef(void* const* )
  54. {
  55.     return &COctetStringTypeInfoGetTypeInfo;
  56. }
  57. template<typename T>
  58. inline
  59. CTypeRef GetSetTypeRef(T* const* )
  60. {
  61.     const T* p = 0;
  62.     return CTypeRef(&CAutoPointerTypeInfoGetTypeInfo, GetAsnStructTypeInfo(p));
  63. }
  64. template<typename T>
  65. inline
  66. CTypeRef GetSequenceTypeRef(T* const* )
  67. {
  68.     const T* p = 0;
  69.     return CTypeRef(&CAutoPointerTypeInfoGetTypeInfo, GetAsnStructTypeInfo(p));
  70. }
  71. template<typename T>
  72. inline
  73. CTypeRef GetSetOfTypeRef(T* const* p)
  74. {
  75.     //    const T* p = 0;
  76.     return CTypeRef(&CSetOfTypeInfoGetTypeInfo, GetSetTypeRef(p));
  77. }
  78. template<typename T>
  79. inline
  80. CTypeRef GetSequenceOfTypeRef(T* const* p)
  81. {
  82.     //    const T* p = 0;
  83.     return CTypeRef(&CSequenceOfTypeInfoGetTypeInfo, GetSetTypeRef(p));
  84. }
  85. inline
  86. CTypeRef GetChoiceTypeRef(TTypeInfo (*func)(void))
  87. {
  88.     return CTypeRef(&CAutoPointerTypeInfoGetTypeInfo, func);
  89. }
  90. template<typename T>
  91. inline
  92. CTypeRef
  93. GetOldAsnTypeRef(const string& name,
  94.                  T* (ASNCALL*newProc)(void),
  95.                  T* (ASNCALL*freeProc)(T*),
  96.                  T* (ASNCALL*readProc)(asnio*, asntype*),
  97.                  unsigned char (ASNCALL*writeProc)(T*, asnio*, asntype*))
  98. {
  99.     return COldAsnTypeInfoGetTypeInfo(name, reinterpret_cast<TAsnNewProc>(newProc), reinterpret_cast<TAsnFreeProc>(freeProc), reinterpret_cast<TAsnReadProc>(readProc), reinterpret_cast<TAsnWriteProc>(writeProc));
  100. }
  101. // old ASN structures info
  102. #define BEGIN_NAMED_ASN_STRUCT_INFO(AsnStructAlias, AsnStructName) 
  103.     BEGIN_TYPE_INFO(NCBI_NAME2(struct_,AsnStructName), 
  104.         ASN_STRUCT_METHOD_NAME(AsnStructName), 
  105.         NCBI_NS_NCBI::CClassTypeInfo, 
  106.         NCBI_NS_NCBI::CClassInfoHelper<CClass>::CreateAsnStructInfo(AsnStructAlias))
  107. #define BEGIN_ASN_STRUCT_INFO(AsnStructName) 
  108.     BEGIN_NAMED_ASN_STRUCT_INFO(#AsnStructName, AsnStructName)
  109. #define END_ASN_STRUCT_INFO END_TYPE_INFO
  110. #define SET_ASN_STRUCT_MODULE(ModuleName) 
  111.     NCBI_NS_NCBI::SetModuleName(info, ModuleName)
  112. #define BEGIN_NAMED_ASN_CHOICE_INFO(AsnChoiceAlias, AsnChoiceName) 
  113.     BEGIN_TYPE_INFO(valnode, 
  114.         ASN_STRUCT_METHOD_NAME(AsnChoiceName), 
  115.         NCBI_NS_NCBI::CChoiceTypeInfo, 
  116.         NCBI_NS_NCBI::CClassInfoHelper<CClass>::CreateAsnChoiceInfo(AsnChoiceAlias))
  117. #define BEGIN_ASN_CHOICE_INFO(AsnChoiceName) 
  118.     BEGIN_NAMED_ASN_CHOICE_INFO(#AsnChoiceName, AsnChoiceName)
  119. #define SET_ASN_CHOICE_MODULE(ModuleName) 
  120.     NCBI_NS_NCBI::SetModuleName(info, ModuleName)
  121. #define END_ASN_CHOICE_INFO END_TYPE_INFO
  122. // adding old ASN members
  123. #define ADD_NAMED_ASN_MEMBER(MemberAlias, MemberName, AsnTypeKind) 
  124.     NCBI_NS_NCBI::AddMember(info,MemberAlias,MEMBER_PTR(MemberName),
  125.         NCBI_NAME3(Get,AsnTypeKind,TypeRef)(MEMBER_PTR(MemberName)))
  126. #define ADD_ASN_MEMBER(MemberName, AsnTypeKind) 
  127.     ADD_NAMED_ASN_MEMBER(#MemberName, MemberName, AsnTypeKind)
  128. #define ADD_NAMED_OLD_ASN_MEMBER(MemberAlias, MemberName, AsnTypeAlias, AsnTypeName) 
  129.     NCBI_NS_NCBI::AddMember(info,MemberAlias,MEMBER_PTR(MemberName), 
  130.     NCBI_NS_NCBI::GetOldAsnTypeRef(AsnTypeAlias, 
  131.         &NCBI_NAME2(AsnTypeName,New), &NCBI_NAME2(AsnTypeName,Free), 
  132.         &NCBI_NAME2(AsnTypeName,AsnRead), &NCBI_NAME2(AsnTypeName,AsnWrite)))
  133. #define ADD_OLD_ASN_MEMBER(MemberName, AsnTypeName) 
  134.     ADD_NAMED_OLD_ASN_MEMBER(#MemberName, MemberName, #AsnTypeName, AsnTypeName)
  135. #define ADD_NAMED_ASN_CHOICE_MEMBER(MemberAlias, MemberName, AsnChoiceName) 
  136.     NCBI_NS_NCBI::AddMember(info,MemberAlias,MEMBER_PTR(MemberName), 
  137.     NCBI_NS_NCBI::GetChoiceTypeRef(ASN_STRUCT_METHOD_NAME(AsnChoiceName)))
  138. #define ADD_ASN_CHOICE_MEMBER(MemberName, AsnChoiceName) 
  139.     ADD_NAMED_ASN_CHOICE_MEMBER(#MemberName, MemberName, AsnChoiceName)
  140. #define ADD_NAMED_ASN_CHOICE_STD_VARIANT(VariantAlias, AsnTypeName) 
  141.     NCBI_NS_NCBI::AddVariant(info,VariantAlias, 
  142.         MEMBER_PTR(data.NCBI_NAME2(AsnTypeName,value)), 
  143.         GetStdTypeInfoGetter(MEMBER_PTR(data.NCBI_NAME2(AsnTypeName,value))))
  144. #define ADD_ASN_CHOICE_STD_VARIANT(VariantName, AsnTypeName) 
  145.     ADD_NAMED_ASN_CHOICE_STD_VARIANT(#VariantName, AsnTypeName)
  146. #define ADD_NAMED_ASN_CHOICE_VARIANT(VariantAlias, AsnTypeKind, AsnTypeName) 
  147.     NCBI_NS_NCBI::AddVariant(info,VariantAlias, 
  148.         MEMBER_PTR(data.ptrvalue), 
  149.         NCBI_NAME3(Get,AsnTypeKind,TypeRef)(reinterpret_cast<NCBI_NAME2(struct_,AsnTypeName)*const*>(MEMBER_PTR(data.ptrvalue))))
  150. #define ADD_ASN_CHOICE_VARIANT(VariantName, AsnTypeKind, AsnTypeName) 
  151.     ADD_NAMED_ASN_CHOICE_VARIANT(#VariantName, AsnTypeKind, AsnTypeName)
  152. END_NCBI_SCOPE
  153. #endif /* HAVE_NCBI_C */
  154. #endif
  155. /* @} */