NCBI C++ ToolKit
id2_client.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: id2_client.cpp 89581 2020-04-08 16:20:52Z ucko $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: .......
27  *
28  * File Description:
29  * .......
30  *
31  * Remark:
32  * This code was originally generated by application DATATOOL
33  * using the following specifications:
34  * 'id2.asn'.
35  */
36 
37 // standard includes
38 #include <ncbi_pch.hpp>
39 
40 // generated includes
43 
44 // generated classes
45 
47 
48 BEGIN_objects_SCOPE // namespace ncbi::objects::
49 
50 // destructor
52 {
53 }
54 
55 
57 {
58  static const STimeout kZeroTimeout = { 0, 0 };
59  Connect();
60  (*m_Out) << packet;
61  dynamic_cast<CConn_ServiceStream&>(*m_Stream).Fetch(&kZeroTimeout);
62 }
63 
64 
65 void CID2Client::JustAsk(const CID2_Request& request)
66 {
67  static const STimeout kZeroTimeout = { 0, 0 };
68  Connect();
69  WriteRequest(*m_Out, request);
70  dynamic_cast<CConn_ServiceStream&>(*m_Stream).Fetch(&kZeroTimeout);
71 }
72 
73 
75 {
76  // send a packet with single request
77  CID2_Request_Packet packet;
78  packet.Set().push_back(Ref(&const_cast<TRequest&>(request)));
79  out << packet;
80 }
81 
82 
84 {
85  m_Replies.clear();
86  // read all replies until 'end-of-reply' is set
87  do {
88  in >> reply;
89  if ( reply.IsSetDiscard() ) {
90  // if 'discard' is set we should ignore the reply
91  continue;
92  }
93  if ( reply.IsSetEnd_of_reply() && reply.CanBeDeleted() ) {
94  // last reply can be stored directly if it's allocated in heap
95  m_Replies.push_back(Ref(&reply));
96  }
97  else {
98  // otherwise we store a copy of the reply
99  m_Replies.push_back(Ref(SerialClone(reply)));
100  }
101  } while ( !reply.IsSetEnd_of_reply() );
102 }
103 
104 
105 END_objects_SCOPE // namespace ncbi::objects::
106 
User-defined methods of the data storage class.
This stream exchanges data with a named service, in a constraint that the service is implemented as o...
TReplies m_Replies
Definition: id2_client.hpp:87
virtual void ReadReply(CObjectIStream &in, TReply &reply)
Definition: id2_client.cpp:83
~CID2Client(void)
Definition: id2_client.cpp:51
void JustAsk(const CID2_Request_Packet &packet)
Definition: id2_client.cpp:56
virtual void WriteRequest(CObjectOStream &out, const TRequest &request)
Definition: id2_client.cpp:74
CID2_Reply –.
Definition: ID2_Reply.hpp:66
CID2_Request_Packet –.
CID2_Request –.
Definition: ID2_Request.hpp:66
CObjectIStream –.
Definition: objistr.hpp:93
CObjectOStream –.
Definition: objostr.hpp:83
std::ofstream out("events_result.xml")
main entry point for tests
EIO_Status Fetch(const STimeout *timeout=kDefaultTimeout)
Flush the stream and fetch the response (w/o extracting any user data)
unique_ptr< CObjectOStream > m_Out
C * SerialClone(const C &src)
Create on heap a clone of the source object.
Definition: serialbase.hpp:512
void Connect(void)
Definition: rpcbase.cpp:145
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
Definition: ncbiobj.hpp:2015
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
Tdata & Set(void)
Assign a value to data member.
bool IsSetEnd_of_reply(void) const
true if this reply is the last one for the request false if more replies will follow Check if a value...
Definition: ID2_Reply_.hpp:904
User-defined methods of the data storage class.
static const STimeout kZeroTimeout
std::istream & in(std::istream &in_, double &x_)
Timeout structure.
Definition: ncbi_types.h:76
Modified on Thu Dec 07 10:10:30 2023 by modify_doxy.py rev. 669887