// $Id$ // // ============================================================================ // // = FILENAME // GPlot_File.h // // = AUTHOR // Tim Harrison // // ============================================================================ #if !defined (ACE_GPlot_File_H) #define ACE_GPlot_File_H #include "ace/Map_Manager.h" #include "ace/Synch.h" class TAO_ORBSVCS_Export ACE_GPlot_File // = TITLE // Reads and writes files in GPlot format. // // = DESCRIPTION // Gplot formats are as follows: // entry value // entry value // entry value // ... // They represent x,y pairs to be graphed by GPlot. entry's are // type long. value's are type long or float. { public: ACE_GPlot_File (void); // Construction. ~ACE_GPlot_File (void); // Destruction. Calls this->close. int open (const char *filename); // If the file does not exist, create it. If the file exists open // the file and read all the entries into map_. Returns 0 on // success, -1 on failure. void close (void); // Close the file and sync all the contents. int get (long entry, long &value); // Get the entry at this value. Returns 0 if a value was found. // Returns -1 if no value has been set for . int get (long entry, float &value); // Get the entry at this value. Returns 0 if a value was found. // Returns -1 if no value has been set for . void set (long entry, long value); // Set the entry at this value. void set (long entry, float value); // Set the entry at this value. void set_greatest (long entry, long value); // Compare with the value at . Store the largest. void set_greatest (long entry, float value); // Compare with the value at . Store the largest. void set_least (long entry, long value); // Compare with the value at . Store the smallest. void set_least (long entry, float value); // Compare with the value at . Store the smallest. void dump (void); // Dump state of the object. private: // = map_ stores all values. It is sync'ed to file when this->close // is called. typedef ACE_Map_Entry GPLOT_ENTRY; typedef ACE_Map_Manager GPLOT_MAP; typedef ACE_Map_Iterator GPLOT_ITERATOR; GPLOT_MAP map_; char filename_[BUFSIZ]; FILE *write_file_; int closed_; // Only close once. }; #if defined (__ACE_INLINE__) #include "GPlot_File.i" #endif /* __ACE_INLINE__ */ #endif /* ACE_GPlot_File_H */