Scopira  20080306
polyflow.h
1 
2 /*
3  * Copyright (c) 2002-2007 National Research Council
4  *
5  * All rights reserved.
6  *
7  * This material is confidential and proprietary information of
8  * National Research Council Canada ("Confidential Information").
9  * This Confidential Information may only be used and reproduced
10  * in accordance with the terms of the license agreement.
11  *
12  */
13 
14 #ifndef __INCLUDED_SCOPIRA_TOOL_POLYFLOW_H__
15 #define __INCLUDED_SCOPIRA_TOOL_POLYFLOW_H__
16 
17 #include <scopira/tool/flow.h>
18 #include <scopira/tool/export.h>
19 
20 #include <typeinfo>
21 #include <map>
22 
23 //
24 // two polymorphic flow implementations
25 // (rouge wave guide, ver 7, p124)
26 //
27 // @author Aleksander Demko
28 //
29 
30 namespace scopira
31 {
32  namespace tool
33  {
34  class polyiflow;
35  class polyoflow;
36  class isoiflow;
37  class isooflow;
38  }
39 }
40 
52 {
53  protected:
54  bool read_object_impl(object* &out);
55  typedef std::map<int, const std::type_info*> typemap_t;
56  count2_ptr< itflow_i > dm_file;
57  typemap_t dm_typemap;
58 
59  public:
60 
62  SCOPIRA_EXPORT polyiflow(bool doref, itflow_i* rz);
63 
65  SCOPIRA_EXPORT virtual ~polyiflow();
66 
68  SCOPIRA_EXPORT virtual bool failed(void) const;
69 
71  SCOPIRA_EXPORT virtual size_t read(byte_t* _buf, size_t _maxsize);
72 
73  SCOPIRA_EXPORT virtual bool read_bool(bool&);
74  SCOPIRA_EXPORT virtual bool read_char(char&);
75  SCOPIRA_EXPORT virtual bool read_short(short&);
76  SCOPIRA_EXPORT virtual bool read_int(int&);
77  SCOPIRA_EXPORT virtual bool read_size_t(size_t&);
78  SCOPIRA_EXPORT virtual bool read_int64_t(int64_t&);
79  SCOPIRA_EXPORT virtual bool read_long(long&);
80  SCOPIRA_EXPORT virtual bool read_float(float&);
81  SCOPIRA_EXPORT virtual bool read_double(double&);
82  SCOPIRA_EXPORT virtual bool read_string(std::string&);
83 
85  SCOPIRA_EXPORT virtual bool read_object(object* &out);
86 
94  SCOPIRA_EXPORT void open(itflow_i* fi);
95 
97  SCOPIRA_EXPORT void close(void);
98 };
99 
111 {
112  protected:
113  typedef std::map<std::string, int> typemap_t;
114  count2_ptr< otflow_i > dm_file;
115  int dm_next_typeid;
116  typemap_t dm_typemap;
117 
118  public:
119 
121  SCOPIRA_EXPORT polyoflow(bool doref, otflow_i* rz);
122 
124  SCOPIRA_EXPORT virtual ~polyoflow();
125 
127  SCOPIRA_EXPORT virtual bool failed(void) const;
128 
130  SCOPIRA_EXPORT virtual size_t write(const byte_t* _buf, size_t _size);
131 
132  SCOPIRA_EXPORT virtual void write_bool(bool val);
133  SCOPIRA_EXPORT virtual void write_char(char val);
134  SCOPIRA_EXPORT virtual void write_short(short val);
135  SCOPIRA_EXPORT virtual void write_int(int val);
136  SCOPIRA_EXPORT virtual void write_size_t(size_t val);
137  SCOPIRA_EXPORT virtual void write_int64_t(int64_t val);
138  SCOPIRA_EXPORT virtual void write_long(long val);
139  SCOPIRA_EXPORT virtual void write_float(float val);
140  SCOPIRA_EXPORT virtual void write_double(double val);
141  SCOPIRA_EXPORT virtual void write_string(const std::string& val);
142 
144  SCOPIRA_EXPORT virtual void write_object(const scopira::tool::object* o);
145 
153  SCOPIRA_EXPORT void open(otflow_i* fi);
154 
156  SCOPIRA_EXPORT void close(void);
157 };
158 
173 {
174  protected:
175  typedef std::map<int, scopira::tool::object*> idmap_t;
176  idmap_t dm_idmap;
177 
178  public:
180  SCOPIRA_EXPORT isoiflow(bool doref, itflow_i* rz);
181 
183  SCOPIRA_EXPORT virtual ~isoiflow();
184 
186  SCOPIRA_EXPORT virtual bool read_object(object* &out);
187 };
188 
203 {
204  protected:
205  typedef std::map<const scopira::tool::object*, int> ptrmap_t;
206  int dm_nextid;
207  ptrmap_t dm_ptrmap;
208 
209  public:
211  SCOPIRA_EXPORT isooflow(bool doref, otflow_i* rz);
212 
214  SCOPIRA_EXPORT virtual ~isooflow();
215 
217  SCOPIRA_EXPORT virtual void write_object(const scopira::tool::object* o);
218 };
219 
220 #endif
221 
Definition: polyflow.h:172
void open(itflow_i *fi)
virtual bool read_long(long &)
scopira::tool::byte_t byte_t
Definition: flow.h:73
virtual size_t read(byte_t *_buf, size_t _maxsize)
read raw block data, returns num read in
Definition: archiveflow.h:20
Definition: flow.h:212
Definition: flow.h:281
Definition: object.h:43
Definition: flow.h:352
virtual bool read_short(short &)
Definition: polyflow.h:110
virtual ~polyiflow()
destructor
Definition: polyflow.h:51
Definition: object.h:71
virtual bool read_double(double &)
polyiflow(bool doref, itflow_i *rz)
constructor + open
void close(void)
closes the current file
virtual bool read_float(float &)
virtual bool read_char(char &)
virtual bool read_string(std::string &)
virtual bool read_bool(bool &)
virtual bool read_object(object *&out)
reads a virtual object from the stream
Definition: polyflow.h:202
Definition: flow.h:421
virtual bool read_size_t(size_t &)
virtual bool read_int(int &)
virtual bool read_int64_t(int64_t &)
virtual bool failed(void) const
are we in a failed state?