00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file XML_Saver.h 00006 * 00007 * $Id: XML_Saver.h 82954 2008-10-07 08:02:58Z johnnyw $ 00008 * 00009 * @author Jonathan Pollack <pollack_j@ociweb.com> 00010 */ 00011 //============================================================================= 00012 00013 #ifndef XML_SAVER_H 00014 #define XML_SAVER_H 00015 #include /**/ "ace/pre.h" 00016 00017 #include "orbsvcs/Notify/Topology_Saver.h" 00018 00019 #include "ace/streams.h" 00020 00021 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00022 #pragma once 00023 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00024 00025 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00026 00027 namespace TAO_Notify 00028 { 00029 00030 /** 00031 * \brief Save Notification Service Topology to an XML file. 00032 */ 00033 class XML_Saver : public Topology_Saver 00034 { 00035 public: 00036 /// Construct an XML_Saver. 00037 /// Initialization is deferred to "open()" 00038 XML_Saver (bool timestamp = true); 00039 00040 virtual ~XML_Saver (); 00041 00042 /// Open the output file. 00043 /// \param file_name the fully qualified file name 00044 /// \return true if successful 00045 bool open (const ACE_TString & file_name, size_t backup_count); 00046 00047 ////////////////////////////////// 00048 // Override Topology_Saver methods 00049 // see Topology_Saver.h for doc 00050 virtual bool begin_object (CORBA::Long id, 00051 const ACE_CString& type, 00052 const NVPList& attrs, 00053 bool changed); 00054 00055 virtual void end_object (CORBA::Long id, 00056 const ACE_CString& type); 00057 00058 virtual void close (void); 00059 00060 private: 00061 void backup_file_name (ACE_TCHAR * file_path, size_t nfile); 00062 00063 private: 00064 /// A stream representing our current output. 00065 FILE * output_; 00066 bool close_out_; 00067 00068 /// the name of the output file 00069 ACE_TString base_name_; 00070 size_t backup_count_; 00071 00072 /// true to enable timestamping 00073 bool timestamp_; 00074 00075 /// A string consisting of spaces that is our current indentation level. 00076 ACE_CString indent_; 00077 00078 }; 00079 00080 } // namespace TAO_Notify 00081 00082 TAO_END_VERSIONED_NAMESPACE_DECL 00083 00084 #include /**/ "ace/post.h" 00085 #endif /* XML_SAVER_H */