My Project
 All Classes Namespaces Functions Friends
Clcm.hxx
1 
13 #ifndef Clcm_HXX
14 #define Clcm_HXX
15 
16 #include <cstddef> // for __GLIBCXX__
17 
18 #ifdef __GLIBCXX__ // for memory management with shared_ptr
19 # include <tr1/memory>
20 #else
21 # ifdef __IBMCPP__
22 # define __IBMCPP_TR1__
23 # endif
24 # include <memory>
25 #endif
26 
27 #include <cerrno>
28 #include <cstdio>
29 #include <cstring>
30 #include <iostream>
31 #include <sstream>
32 #include <vector>
33 #include <fstream>
34 #include <complex>
35 #include<boost/shared_ptr.hpp>
36 #include<boost/shared_array.hpp>
37 #include<boost/variant.hpp>
38 #include "LCMexception.hxx"
39 extern "C" {
40 #include <dirent.h>
41 #include "lcm.h"
42 }
43 
44 #define IntPtr boost::shared_array<int_32>
45 #define FloatPtr boost::shared_array<float_32>
46 #define StringPtr boost::shared_ptr<std::string>
47 #define DoublePtr boost::shared_array<double_64>
48 #define BoolPtr boost::shared_array<bool>
49 #define ComplexPtr boost::shared_array< std::complex<float_32> >
50 #define StringVecPtr boost::shared_ptr< std::vector<std::string> >
51 #define ClcmPtr boost::shared_ptr<Clcm>
52 
53 // support for pinning.
54 #define AnyPtr boost::variant<IntPtr, FloatPtr, StringPtr, DoublePtr, BoolPtr, ComplexPtr>
55 #define IntPtrConst boost::shared_array<const int_32>
56 #define FloatPtrConst boost::shared_array<const float_32>
57 #define StringPtrConst boost::shared_ptr<const std::string>
58 #define DoublePtrConst boost::shared_array<const double_64>
59 #define BoolPtrConst boost::shared_array<const bool>
60 #define ComplexPtrConst boost::shared_array<const std::complex<float_32> >
61 
62 namespace ganlib {
63 
101 class Clcm {
102 public:
143  Clcm(const std::string stype, const std::string myName, const std::string myPath) throw(LCMexception);
144 
146  Clcm(lcm *, Clcm *, const int_32, const std::string, const int_32, const std::string) throw(LCMexception);
148 
164  Clcm(const std::string stype, ClcmPtr myClcm) throw(LCMexception);
165 
174  Clcm(lcm *mylcm, const int_32 type, const int_32 access, const std::string OSname);
175 
179  ~Clcm();
180 
190  friend std::ostream & operator<<(std::ostream &s, ClcmPtr myClcm) throw(LCMexception);
191 
202  void expor(const std::string stype);
203 
215  void expor(const std::string stype, const std::string new_name);
216 
219  void except();
220 
223  std::string getName() throw();
224 
227  std::string getPath() throw();
228 
234  int_32 getType() throw();
235 
240  int_32 getLength() throw(LCMexception);
241 
247  std::string getDirectory() throw(LCMexception);
248 
253  int_32 getAccess() throw(LCMexception);
254 
257  int_32 getLrda() throw();
258 
261  int_32 getVersion() throw();
262 
266  bool isEmpty() throw(LCMexception);
267 
271  bool isNew() throw();
272 
284  void open(const std::string saccess) throw(LCMexception);
285 
290  void close(const std::string saccess) throw(LCMexception);
291 
300  int_32 length(const std::string key) throw(LCMexception);
301 
311  int_32 length(const int_32 iset) throw(LCMexception);
312 
321  int_32 type(const std::string key) throw(LCMexception);
322 
332  int_32 type(const int_32 iset) throw(LCMexception);
333 
337  void lib() throw(LCMexception);
338 
343  void val() throw(LCMexception);
344 
350  ClcmPtr setDictionary(const std::string key) throw(LCMexception);
351 
358  ClcmPtr setDictionary(const int_32 iset) throw(LCMexception);
359 
366  ClcmPtr setList(const std::string key, const int_32 ilong) throw(LCMexception);
367 
375  ClcmPtr setList(const int_32 iset, const int_32 ilong) throw(LCMexception);
376 
382  ClcmPtr getClcm(const std::string key) throw(LCMexception);
383 
390  ClcmPtr getClcm(const int_32 iset) throw(LCMexception);
391 
406  IntPtrConst getInt(const std::string key) throw(LCMexception);
407 
415  IntPtrConst getInt(const int_32 iset) throw(LCMexception);
416 
423  FloatPtrConst getFloat(const std::string key) throw(LCMexception);
424 
432  FloatPtrConst getFloat(const int_32 iset) throw(LCMexception);
433 
440  StringPtrConst getString(const std::string key) throw(LCMexception);
441 
449  StringPtrConst getString(const int_32 iset) throw(LCMexception);
450 
459  StringVecPtr getVecString(const std::string key, const int_32 size) throw(LCMexception);
460 
470  StringVecPtr getVecString(const int_32 iset, const int_32 size) throw(LCMexception);
471 
478  DoublePtrConst getDouble(const std::string key) throw(LCMexception);
479 
487  DoublePtrConst getDouble(const int_32 iset) throw(LCMexception);
488 
495  BoolPtrConst getBool(const std::string key) throw(LCMexception);
496 
504  BoolPtrConst getBool(const int_32 iset) throw(LCMexception);
505 
512  ComplexPtrConst getComplex(const std::string key) throw(LCMexception);
513 
521  ComplexPtrConst getComplex(const int_32 iset) throw(LCMexception);
522 
529  StringVecPtr keys() throw(LCMexception);
530 
546  void put(const std::string key, IntPtr myArray, const int_32 myLength) throw(LCMexception);
547 
555  void put(const int_32 iset, IntPtr myArray, const int_32 myLength) throw(LCMexception);
556 
563  void put(const std::string key, FloatPtr myArray, const int_32 myLength) throw(LCMexception);
564 
572  void put(const int_32 iset, FloatPtr myArray, const int_32 myLength) throw(LCMexception);
573 
579  void put(const std::string key, StringPtr myArray) throw(LCMexception);
580 
586  void put(const int_32 iset, StringPtr myArray) throw(LCMexception);
587 
594  void put(const std::string key, StringVecPtr myArray) throw(LCMexception);
595 
603  void put(const int_32 iset, StringVecPtr myArray) throw(LCMexception);
604 
611  void put(const std::string key, DoublePtr myArray, const int_32 myLength) throw(LCMexception);
612 
620  void put(const int_32 iset, DoublePtr myArray, const int_32 myLength) throw(LCMexception);
621 
628  void put(const std::string key, BoolPtr myArray, const int_32 myLength) throw(LCMexception);
629 
637  void put(const int_32 iset, BoolPtr myArray, const int_32 myLength) throw(LCMexception);
638 
654  void put(const std::string key, ComplexPtr myArray, const int_32 myLength) throw(LCMexception);
655 
663  void put(const int_32 iset, ComplexPtr myArray, const int_32 myLength) throw(LCMexception);
664 
670  void put(const std::string key, ClcmPtr myClcm) throw(LCMexception);
671 
678  void put(const int_32 iset, ClcmPtr myClcm) throw(LCMexception);
679 
683  lcm *extract();
684 
685 private:
686  std::vector<AnyPtr> *global_list; // container for the global references
687  lcm *addr; // address of the LCM object
688  Clcm *root; // address of Clcm root object
689  std::ofstream aFile; // embedded file if type >= 3
690  int_32 lrda; // used with direct access files only
691  std::string name; // object name
692  std::string path; // path to access the Clcm file to import
693  std::string nammy; // directory name inside LCM object
694  bool empty; // empty flag
695  int_32 ilong; // -1 (dictionary) or list length
696  int_32 objtype; // type of the object =1: LCM; =2: XSM; =3: binary Fortran file
697  // =4: ASCII Fortran file; =5: direct access Fortran file
698  int_32 access; // =0: closed object; =1: object in read/write mode
699  // =2: object in read-only mode
700  int_32 version; // original ganlib version of object
701  bool untoutched; // brand new object flag
702  bool isroot; // true if addr is pointing on the root object
703 }; // class Clcm
704  std::ostream & operator<<(std::ostream &, ClcmPtr) throw(LCMexception);
705 
706 } // namespace ganlib
707 #endif