1 /*------------------------------------------------------------------------------
2 Name: FileWriter.h
3 Project: xmlBlaster.org
4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
5 ------------------------------------------------------------------------------*/
6 #ifndef _CONTRIB_FILEWRITER_H
7 #define _CONTRIB_FILEWRITER_H
8
9 #include <util/xmlBlasterDef.h>
10 #include <contrib/FileWriterCallback.h>
11 #include <util/Global.h>
12 #include <util/qos/ConnectQos.h>
13 #include <client/I_ConnectionProblems.h>
14 #include <client/I_Callback.h>
15 #include <util/thread/ThreadImpl.h>
16 #include <util/dispatch/I_PostSendListener.h>
17 #include <util/ReferenceCounterBase.h>
18 #include <util/ReferenceHolder.h>
19 #include <client/XmlBlasterAccess.h>
20
21 #include <string>
22 #include <vector>
23 #include <map>
24
25 /* The following comment is used by doxygen for the main html page: */
26 /*! \mainpage Hints about the C++ client library usage.
27 *
28 * \section intro_sec The C++ client library
29 *
30 * The xmlBlaster C++ client library supports access to xmlBlaster with asynchronous callbacks,
31 * client side queuing and fail safe reconnect using the CORBA or SOCKET protocol plugin.
32 * Details about compilation and its usage can be found in the
33 * http://www.xmlblaster.org/xmlBlaster/doc/requirements/client.cpp.html requirement.
34 *
35 * As a C++ developer your entry point to use is the class org::xmlBlaster::client::FileWriterCallback and
36 * a complete overview demo code is HelloWorld2.cpp
37 *
38 * \section c_sec The C client library
39 * The C client library offers some basic functionality like the SOCKET protocol with
40 * the struct #FileWriterCallbackUnparsed or persistent queues with struct #I_Queue.
41 * These features are heavily used by the C++ library.
42 * If you need a tiny xmlBlaster access you can choose to use the C client library directly
43 * without any C++ code.
44 *
45 * For details read the
46 * http://www.xmlblaster.org/xmlBlaster/doc/requirements/client.c.socket.html requirement and the
47 * http://www.xmlblaster.org/xmlBlaster/doc/requirements/client.c.queue.html requirement.
48 * and look at the API documentation at http://www.xmlblaster.org/xmlBlaster/doc/doxygen/c/html/index.html
49 */
50
51 // Note: I_ConnectionProblems.h includes I_ConnectionsHandler.h includes I_XmlBlasterConnection.h
52 // which includes all EraseQos, SubscribeKey etc.
53 // -> We could try to avoid this by forward declaration, but all cpp files must
54 // then include them thereselves.
55
56 // Declare classes without the need to include them in this header file
57 namespace org { namespace xmlBlaster { namespace util {
58 class MessageUnit;
59 }}}
60 namespace org { namespace xmlBlaster { namespace util { namespace dispatch {
61 class DispatchManager;
62 class ConnectionsHandler;
63 }}}}
64 namespace org { namespace xmlBlaster { namespace client { namespace protocol {
65 class I_CallbackServer;
66 }}}}
67
68 namespace org { namespace xmlBlaster { namespace contrib {
69
70 /*
71 * The interface org::xmlBlaster::client::I_CallbackRaw/I_Callback/I_CallbackExtended are enforced by AbstractCallbackExtended
72 * is for the protocol drivers.
73 */
74 typedef std::map<std::string, org::xmlBlaster::client::I_Callback*> CallbackMapType;
75 typedef std::map<std::string, std::string> StringMap;
76
77 /**
78 * This is the main entry point for programmers to the C++ client library.
79 *
80 * Exactly one Global instance and one instance of this are a pair which can't be
81 * mixed with other instances.
82 */
83 class Dll_Export FileWriter : public org::xmlBlaster::client::I_Callback
84 {
85 private:
86
87 std::string ME;
88 org::xmlBlaster::util::Global& global_;
89 org::xmlBlaster::util::I_Log& log_;
90
91 std::string subscribeKey_;
92 std::string subscribeQos_;
93
94 /** only used as a default login name and logging */
95 std::string name_;
96 bool momAdministered_;
97
98 org::xmlBlaster::client::XmlBlasterAccess *access_;
99 org::xmlBlaster::util::qos::ConnectQosRef connectQos_;
100 FileWriterCallback *callback_;
101
102 /**
103 * Connects to the xmlBlaster.
104 *
105 * @throws XmlBlasterException
106 */
107 void initConnection();
108
109 public:
110 FileWriter(org::xmlBlaster::util::Global &globOrig, std::string &name);
111
112 void init();
113
114 /**
115 * If an exception occurs it means it could not publish the entry
116 * @throws XmlBlasterException
117 */
118 void shutdown();
119
120 std::string update(const std::string &sessionId,
121 org::xmlBlaster::client::key::UpdateKey &updateKey,
122 const unsigned char *content, long contentSize,
123 org::xmlBlaster::client::qos::UpdateQos &updateQos);
124
125 virtual ~FileWriter();
126
127 };
128
129 typedef org::xmlBlaster::util::ReferenceHolder<org::xmlBlaster::contrib::FileWriter> FileWriterRef;
130
131 }}} // namespaces
132
133 #endif
syntax highlighted by Code2HTML, v. 0.9.1