Annotation of parser3/src/include/pa_charset_connection.h, revision 1.5

1.1       parser      1: /** @file
                      2:        Parser: Charset connection decl.
                      3: 
                      4:        Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.4       paf         5:        Author: Alexander Petrosyan <paf@design.ru> (http://paf.design.ru)
1.1       parser      6: 
1.5     ! paf         7:        $Id: pa_charset_connection.h,v 1.4 2001/11/05 11:46:23 paf Exp $
1.1       parser      8: */
                      9: 
                     10: #ifndef PA_CHARSET_CONNECTION_H
                     11: #define PA_CHARSET_CONNECTION_H
                     12: 
                     13: #include "pa_config_includes.h"
                     14: #include "pa_pool.h"
                     15: #include "pa_exception.h"
                     16: #include "pa_common.h"
1.5     ! paf        17: #include "pa_transcoder.h"
1.1       parser     18: 
                     19: // defines
                     20: 
                     21: /**    Connection with charset file: 
                     22:        remembers time and can figure out that it needs recompilation
                     23: */
                     24: class Charset_connection : public Pooled {
                     25: public:
                     26: 
                     27:        Charset_connection(Pool& pool, const String& aname, const String& afile_spec) : Pooled(pool),
                     28:                fname(aname),
                     29:                ffile_spec(afile_spec),
                     30:                prev_disk_time(0) {
                     31:        }
1.2       parser     32:        ~Charset_connection() {}
1.3       paf        33:        const String& get_file_spec() { return ffile_spec; }
1.1       parser     34:        
                     35:        void up_to_date(Pool& pool) { 
                     36:                time_t new_disk_time=get_new_disk_time();
                     37:                if(new_disk_time)
                     38:                        load(pool, new_disk_time);
                     39:        }
                     40: 
1.5     ! paf        41:        Transcoder& transcoder() { return ftranscoder; }
1.1       parser     42: 
                     43: private:
                     44: 
                     45:        time_t get_new_disk_time() {
                     46:                time_t now_disk_time=get_disk_time();
                     47:                return now_disk_time>prev_disk_time?now_disk_time:0;
                     48:        }
                     49: 
                     50:        void load(Pool& pool, time_t new_disk_time);
                     51:        
                     52:        time_t get_disk_time() {
                     53:                size_t size;
                     54:                time_t atime, mtime, ctime;
                     55:                // {file_spec} modification time
1.2       parser     56:                file_stat(ffile_spec, 
1.1       parser     57:                        size,
                     58:                        atime, mtime, ctime,
1.2       parser     59:                        true/*exception on error*/);
1.1       parser     60:                return mtime;
                     61:        }
                     62: 
                     63: private:
                     64: 
                     65:        const String& fname;
                     66:        const String& ffile_spec;
                     67:        time_t prev_disk_time;
                     68: 
1.5     ! paf        69:        Transcoder ftranscoder;
        !            70: 
1.1       parser     71: };
                     72: 
                     73: #endif

E-mail: