00001 //# record.h: dictionary of variants 00002 //# 00003 //# Copyright (C) 2011 00004 //# Associated Universities, Inc. Washington DC, USA. 00005 //# 00006 //# This library is free software; you can redistribute it and/or modify it 00007 //# under the terms of the GNU Library General Public License as published by 00008 //# the Free Software Foundation; either version 2 of the License, or (at your 00009 //# option) any later version. 00010 //# 00011 //# This library is distributed in the hope that it will be useful, but WITHOUT 00012 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00014 //# License for more details. 00015 //# 00016 //# You should have received a copy of the GNU Library General Public License 00017 //# along with this library; if not, write to the Free Software Foundation, 00018 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00019 //# 00020 //# Correspondence concerning AIPS++ should be addressed as follows: 00021 //# Internet email: aips2-request@nrao.edu. 00022 //# Postal address: AIPS++ Project Office 00023 //# National Radio Astronomy Observatory 00024 //# 520 Edgemont Road 00025 //# Charlottesville, VA 22903-2475 USA 00026 //# 00027 //# $Id$ 00028 00029 #ifndef __casadbus_record_h__ 00030 #define __casadbus_record_h__ 00031 00032 #include <map> 00033 #include <string> 00034 #include <casadbus/types/variant.h> 00035 00036 namespace casa { 00037 namespace dbus { 00038 00039 typedef std::map<std::string,variant> rec_map; 00040 00041 // todo: o create python to/from record functions 00042 // o implement compare() 00043 // o implement record_to_string() 00044 // o create a thorough test program 00045 // o verify that std::map<>'s copy ctor does a complete copy 00046 // o add copy-on-write (w/ reference counting) 00047 // 00048 class record : public rec_map { 00049 public: 00050 typedef rec_map::iterator iterator; 00051 typedef rec_map::const_iterator const_iterator; 00052 typedef rec_map::value_type value_type; 00053 00054 record(); 00055 record *clone() const { return new record(*this); } 00056 int compare(const record*) const; 00057 00058 record( const record &r ) : rec_map(r) { } 00059 record &operator=(const record &r) { rec_map::operator=(r); return *this; } 00060 std::pair<rec_map::iterator,bool> insert(const std::string &s,const variant &v); 00061 }; 00062 00063 } // dbus namespace 00064 } // casa namespace 00065 00066 #endif