LayerManagerCommands: log screen/layer/surface IDs in decimal and hex
[profile/ivi/layer-management.git] / LayerManagerCommands / src / LayerSetRenderOrderCommand.cpp
1 /***************************************************************************
2 *
3 * Copyright 2010,2011 BMW Car IT GmbH
4 *
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 *        http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 ****************************************************************************/
19 #include "LayerSetRenderOrderCommand.h"
20 #include "ICommandExecutor.h"
21 #include "Scene.h"
22 #include "Log.h"
23
24 LayerSetRenderOrderCommand::~LayerSetRenderOrderCommand()
25 {
26     delete[] m_array;
27 }
28
29 ExecutionResult LayerSetRenderOrderCommand::execute(ICommandExecutor* executor)
30 {
31     Scene& scene = *(executor->getScene());
32
33     ExecutionResult result = ExecutionFailed;
34
35     Layer* layer = scene.getLayer(m_layerid);
36
37     if (layer)
38     {
39         result = layer->removeAllSurfaces() ? ExecutionSuccessRedraw : ExecutionSuccess;
40
41         for (unsigned int surfaceIndex = 0; surfaceIndex < m_length; ++surfaceIndex)
42         {
43             Surface* surface = scene.getSurface(m_array[surfaceIndex]);
44
45             if (surface)
46             {
47                 unsigned int layer_id = surface->getContainingLayerId();
48                 if (layer->addSurface(surface))
49                 {
50                     LOG_DEBUG("LayerSetRenderOrderCommand","Adding surface " << surface->getID() << " to renderorder of layer " << m_layerid);
51                     result = ExecutionSuccessRedraw;
52                 }
53                 else
54                 {
55                     LOG_WARNING("LayerSetRenderOrderCommand","surface : id [ " << m_array[surfaceIndex] << " ] already belongs to layer : id [ " << layer_id << " ]");
56                 }
57             }
58         }
59     }
60
61     return result;
62 }
63
64 const std::string LayerSetRenderOrderCommand::getString()
65 {
66     std::stringstream description;
67     description << "LayerSetRenderOrderCommand("
68                 << "layerid=" << m_layerid << "(0x" << std::hex << m_layerid << ")" << std::dec
69                 << ", m_array=[";
70
71     for (unsigned int i = 0; i < m_length; ++i)
72     {
73         description << m_array[i] << ",";
74     }
75     description << "], m_length=" << m_length
76                 << ")";
77     return description.str();
78 }