Confdump Agent  1.4.0
Result.cpp
Go to the documentation of this file.
00001 /* 
00002  * Confdump-Agent - Dump static and runtime system configuration
00003  * Copyright (C) 2009-2012  Straton IT, SAS
00004  * 
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 3 as
00007  * published by the Free Software Foundation.
00008  * 
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #include <iterator>
00019 
00020 #include <QMetaObject>
00021 #include <QMetaProperty>
00022 
00023 #include "boost/foreach.hpp"
00024 #include "boost/shared_ptr.hpp"
00025 
00026 #include "Confdump/System/ManagedElement.hpp"
00027 #include "Confdump/Result.hpp"
00028 
00029 using boost::shared_ptr;
00030 
00031 namespace Confdump
00032 {
00033 
00034 Result::Result()
00035 {
00036 }
00037 
00038 Result::~Result()
00039 {
00040 }
00041 
00042 Result::const_iterator Result::begin() const
00043 {
00044     return rows_.begin();
00045 }
00046 
00047 Result::const_iterator Result::end() const
00048 {
00049     return rows_.end();
00050 }
00051 
00052 void Result::addRow( Result::Row row )
00053 {
00054     // Copy the static properties
00055     const QMetaObject* metaObject = row->metaObject();
00056     for ( int i = metaObject->propertyOffset(); i < metaObject->propertyCount(); ++i )
00057         properties_.insert( QString::fromLatin1( metaObject->property( i ).name() ) );
00058 
00059     BOOST_FOREACH( const QByteArray &name, row->dynamicPropertyNames() )
00060         properties_.insert( QString::fromLatin1( name ) );
00061 
00062     rows_.push_back( row );
00063 }
00064 
00065 QStringList Result::propertyNames() const
00066 {
00067     QStringList props;
00068 
00069     copy( properties_.begin(), properties_.end(), std::back_inserter( props ) );
00070 
00071     return props;
00072 }
00073 
00074 QList<QVariant> Result::propertyValues( Result::Row row ) const
00075 {
00076     QStringList names = propertyNames();
00077     QList<QVariant> values;
00078 
00079     BOOST_FOREACH( QString name, names )
00080     {
00081         values.push_back( row->property( name.toLatin1() ) );
00082     }
00083 
00084     return values;
00085 }
00086 
00087 }
00088 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends