summaryrefslogtreecommitdiffstats
path: root/src/applist.hpp
blob: 085504acd720d8a6e4a9fcabe21079b6298571de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyword.Type */
.highlight .ld { color: #e6db74 } /* Literal.Date */
.highlight .m { color: #ae81ff } /* Literal.Number */
.highlight .s { color: #e6db74 } /* Literal.String */
.highlight .na { color: #a6e22e } /* Name.Attribute */
.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
.highlight .nc { color: #a6e22e } /* Name.Class */
.highlight .no { color: #66d9ef } /* Name.Constant */
.highlight .nd { color: #a6e22e } /* Name.Decorator */
.highlight .ni { color: #f8f8f2 } /* Name.Entity */
.highlight .ne { color: #a6e22e } /* Name.Exce
/*
 * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ALLOCATE_LIST_HPP
#define ALLOCATE_LIST_HPP
#include <vector>
#include <string>
#include <map>
#include <memory>
#include <mutex>
#include "wm_client.hpp"
#include "request.hpp"
#include "wm_error.hpp"

namespace wm
{

/* using std::experimental::nullopt;
using std::experimental::optional; */

class AppList
{
  public:
    AppList();
    virtual ~AppList();
    AppList(const AppList &obj) = delete;

    // Client Database Interface
    /* TODO: consider, which is better WMClient as parameter or not
       If the WMClient should be more flexible, I think this param should be WMClient class
    */
    void addClient(const std::string &appid, unsigned layer,
                    unsigned surface, const std::string &role);
    void addClient(const std::string &appid, unsigned layer, const std::string &role);
    void removeClient(const std::string &appid);
    bool contains(const std::string &appid) const;
    int  countClient() const;
    std::shared_ptr<WMClient> lookUpClient(const std::string &appid);
    void removeSurface(unsigned surface);
    std::string getAppID(unsigned surface, bool* found) const; // TODO: remove

    // Request Interface
    unsigned currentRequestNumber() const;
    unsigned getRequestNumber(const std::string &appid) const;
    unsigned addRequest(WMRequest req);
    WMError setAction(unsigned req_num, const struct WMAction &action);
    WMError setAction(unsigned req_num, std::shared_ptr<WMClient> client,
                    const std::string &role, const std::string &area, TaskVisible visible);
    bool setEndDrawFinished(unsigned req_num, const std::string &appid, const std::string &role);
    bool endDrawFullfilled(unsigned req_num);
    void removeRequest(unsigned req_num);
    void next();
    bool haveRequest() const;

    struct WMTrigger getRequest(unsigned req_num, bool* found);
    const std::vector<struct WMAction> &getActions(unsigned req_num, bool* found);

    void clientDump();
    void reqDump();

  private:
    std::vector<WMRequest> req_list;
    std::unordered_map<std::string, std::shared_ptr<WMClient>> app2client;
    unsigned current_req;
    std::mutex mtx;
};

} // namespace wm
#endif // ALLOCATE_LIST_HPP