Back to index

unity  6.0.0
ModelRowAdaptor.h
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: Neil Jagdish Patel <neil.patel@canonical.com>
00018  */
00019 
00020 #ifndef UNITY_MODEL_ROW_H
00021 #define UNITY_MODEL_ROW_H
00022 
00023 #include <string>
00024 
00025 #include <dee.h>
00026 
00027 namespace unity
00028 {
00029 namespace dash
00030 {
00031 
00032 /* RowAdaptors represent a row of a Model<RowAdaptorType> in a form that's easily
00033  * accessible for consumers of the Model. It means you can convert the
00034  * added/removed/changed signals from a pointer to the DeeModelIter to, for example,
00035  * a Dash Category, which represents the data in that DeeModelIter in an easy to use
00036  * manner.
00037  *
00038  * You should not expect to keep a RowAdaptor class around, rather you should use
00039  * the set_renderer() and renderer() functions to store a pointer to your view on
00040  * the row on the added signal. That means that you can easily access the matching
00041  * view to a RowAdaptor that you receive via the changed or removed signals.
00042  *
00043  * Finally, RowAdaptors are expected to be stack-allocated and extremly quick to
00044  * initialize and use (there might be thousands of results to display), therefore
00045  * it is expected that sub-classes continue the trend of a very light
00046  * construction, ideally involving no memory allocation.
00047  */
00048 class RowAdaptorBase
00049 {
00050 public:
00051   RowAdaptorBase(DeeModel* model=0, DeeModelIter* iter=0, DeeModelTag* tag=0);
00052   RowAdaptorBase(RowAdaptorBase const& other);
00053   RowAdaptorBase& operator=(RowAdaptorBase const& other);
00054 
00055   std::string GetStringAt(int position);
00056   bool GetBoolAt(int position);
00057   unsigned int GetUIntAt(int position);
00058 
00059   template<typename T>
00060   void set_renderer(T renderer);
00061 
00062   template<typename T>
00063   T renderer();
00064 
00065 protected:
00066   DeeModel* model_;
00067   DeeModelIter* iter_;
00068   DeeModelTag* tag_;
00069 };
00070 
00071 }
00072 }
00073 
00074 #include "ModelRowAdaptor-inl.h"
00075 
00076 #endif