casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
record.h
Go to the documentation of this file.
1 //# record.h: dictionary of variants
2 //#
3 //# Copyright (C) 2011
4 //# Associated Universities, Inc. Washington DC, USA.
5 //#
6 //# This library is free software; you can redistribute it and/or modify it
7 //# under the terms of the GNU Library General Public License as published by
8 //# the Free Software Foundation; either version 2 of the License, or (at your
9 //# option) any later version.
10 //#
11 //# This library is distributed in the hope that it will be useful, but WITHOUT
12 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14 //# License for more details.
15 //#
16 //# You should have received a copy of the GNU Library General Public License
17 //# along with this library; if not, write to the Free Software Foundation,
18 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
19 //#
20 //# Correspondence concerning AIPS++ should be addressed as follows:
21 //# Internet email: aips2-request@nrao.edu.
22 //# Postal address: AIPS++ Project Office
23 //# National Radio Astronomy Observatory
24 //# 520 Edgemont Road
25 //# Charlottesville, VA 22903-2475 USA
26 //#
27 //# $Id$
28 
29 #ifndef __casadbus_record_h__
30 #define __casadbus_record_h__
31 
32 #include <map>
33 #include <string>
34 #include <casadbus/types/variant.h>
35 
36 namespace casa {
37  namespace dbus {
38 
39  typedef std::map<std::string,variant> rec_map;
40 
41  // todo: o create python to/from record functions
42  // o implement compare()
43  // o implement record_to_string()
44  // o create a thorough test program
45  // o verify that std::map<>'s copy ctor does a complete copy
46  // o add copy-on-write (w/ reference counting)
47  //
48  class record : public rec_map {
49  public:
50  typedef rec_map::iterator iterator;
52  typedef rec_map::value_type value_type;
53 
54  record();
55  record *clone() const { return new record(*this); }
56  int compare(const record*) const;
57 
58  record( const record &r ) : rec_map(r) { }
59  record &operator=(const record &r) { rec_map::operator=(r); return *this; }
60  std::pair<rec_map::iterator,bool> insert(const std::string &s,const variant &v);
61  };
62 
63  } // dbus namespace
64 } // casa namespace
65 
66 #endif
Elements::const_iterator const_iterator
rec_map::const_iterator const_iterator
Definition: record.h:51
int compare(const record *) const
rec_map::iterator iterator
Definition: record.h:50
PtrHolder< T > & operator=(const PtrHolder< T > &other)
record & operator=(const record &r)
Definition: record.h:59
todo: o create python to/from record functions o implement compare() o implement record_to_string() o...
Definition: record.h:48
std::pair< rec_map::iterator, bool > insert(const std::string &s, const variant &v)
std::map< std::string, variant > rec_map
Definition: record.h:39
rec_map::value_type value_type
Definition: record.h:52
record * clone() const
Definition: record.h:55
record(const record &r)
Definition: record.h:58