Back to index

unity  6.0.0
AggregateMonitor.cpp
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003 * Copyright (C) 2011 Canonical Ltd
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 * Authored by: Alex Launi <alex.launi@canonical.com>
00018 */
00019 
00020 #include "AggregateMonitor.h"
00021 #include "ElapsedTimeMonitor.h"
00022 #include <UnityCore/Variant.h>
00023 
00024 namespace unity {
00025 namespace performance {
00026 
00027 AggregateMonitor::AggregateMonitor()
00028 {
00029   _monitors.push_back(new ElapsedTimeMonitor());
00030 }
00031 
00032 AggregateMonitor::~AggregateMonitor()
00033 {
00034 }
00035 
00036 std::string AggregateMonitor::GetName() const
00037 {
00038   return "AggregateMonitor";
00039 }
00040 
00041 void AggregateMonitor::StartMonitor()
00042 {
00043   for (std::list<Monitor*>::iterator iter = _monitors.begin(), end = _monitors.end();
00044        iter != end; ++iter)
00045   {
00046     Monitor* monitor = *iter;
00047     monitor->Start();
00048   }
00049 }
00050 
00051 void AggregateMonitor::StopMonitor(GVariantBuilder* builder)
00052 {
00053   variant::BuilderWrapper wrapper(builder);
00054   for (std::list<Monitor*>::iterator iter = _monitors.begin(), end = _monitors.end();
00055        iter != end; ++iter)
00056   {
00057     Monitor* monitor = *iter;
00058     wrapper.add(monitor->GetName().c_str(), monitor->Stop());
00059   }
00060 }
00061 
00062 }
00063 }