Main Page · Modules · All Classes · Class Hierarchy
MAPacketCache.hpp
1 /*
2  * This file is part of the AiBO+ project
3  *
4  * Copyright (C) 2005-2016 Csaba Kertész (csaba.kertesz@gmail.com)
5  *
6  * AiBO+ is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * AiBO+ is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
19  *
20  */
21 
22 #pragma once
23 
24 #include <map>
25 
26 #include <MCDefs.hpp>
27 
28 class MCBinaryData;
29 
35 namespace MA
36 {
38 typedef std::map<int, MCBinaryData*> PacketCacheMap;
39 }
40 
45 {
47 
48  explicit MAPacketCache(unsigned int storage_size_limit);
49  virtual ~MAPacketCache();
50 
51  void AddPacket(int index, MCBinaryData& packet);
52  MCBinaryData* GetPacket(int index);
53  int GetCurrentStorageSize() const;
54  bool UploadPacket(int index);
55  void Release();
56 
57 protected:
58  virtual void Add(int index, MCBinaryData& packet) = 0;
59  virtual bool Upload(int index, const MCBinaryData& packet) = 0;
60 
66  MA::PacketCacheMap Packets;
67 };
68 
int StorageSizeLimit
Storage size limit in bytes.
Binary data class.
int CurrentStorageSize
Current storage size.
Indexer< T > index(T &t)
Iterator magic for for loops to get the index while iterating through.
Definition: MCDefs.hpp:146
#define MC_DISABLE_COPY(class_name)
Helper macro to disable the copy constructor and assignment operator of a class (object copying) ...
Definition: MCDefs.hpp:604
MA::PacketCacheMap Packets
Image cache.
Packet cache.