Revision 6368bb51 include/MarketPlaceAppPool.h

View differences:

include/MarketPlaceAppPool.h
73 73
     *    @param template to generate app with the from_template64 function
74 74
     *    @param mp_id of the MarketPlace to store de App
75 75
     *    @param mp_name of the MarketPlace
76
     *    @param app_id of the imported app
76 77
     *    @param error_str Returns the error reason, if any
77 78
     *
78 79
     *    @return the oid assigned to the object, -1 in case of failure, -2
79 80
     *    already imported
80 81
     */
81 82
    int import(const std::string& t64, int mp_id, const std::string& mp_name,
82
            std::string& error_str);
83
            int& app_id, std::string& error_str);
83 84

  
84 85
    /**
85 86
     *  Function to get a MarketPlaceApp from the pool
......
147 148
    };
148 149

  
149 150
    /**
150
     * Erease map element
151
     * Check an element into map
152
     *   @param map_id of the app
153
     *   @return true if the app has to be deleted
151 154
     */
152
    void drop_map_check(const std::string& name){
153
        if (map_check.find( name ) != map_check.end()){
154
            map<std::string,int>::iterator it;
155
            it=map_check.find(name);
156
            map_check.erase (it);
157
        }
158
    }
155
    bool test_map_check(int map_id);
159 156

  
160 157
    /**
161
     * Check an element into map
158
     *  Resets the counter of missing monitors of an app
159
     *    @param app_id of the app
162 160
     */
163
    bool test_map_check(const std::string& name){
164
        map_check[name]++;
165
        if (map_check[name] > 0){
166
            return true;
167
        }
168
        return false;
169
    }
161
    void reset_map_check(int app_id);
162

  
170 163
private:
171
    map<std::string, int> map_check;
172

  
173
    
174
    void insert_map_check(const std::string& name){
175
        map_check.insert(make_pair(name, -1));
176
    }
177
    void reset_map_check(const std::string& name){
178
        if (name != "") {
179
            if (map_check.find( name ) != map_check.end()){
180
                map_check[name] = -1;
181
            }
182
            else{
183
                insert_map_check(name);
184
            }
185
        }
186
    }
164

  
165
    /**
166
     *  Hash to store the number of times an app was missing from monitor data
167
     */
168
    map<int, int> map_check;
169

  
170
    /**
171
     *  Max number of monitor that an app may be missing before deleting it
172
     */
173
    static const int MAX_MISSING_MONITORS;
187 174
};
188 175

  
189 176
#endif /*MARKETPLACE_POOL_H_*/

Also available in: Unified diff