main.cpp/physics.h: add some (somewhat icky) compile fixes for OS X
[openc2e.git] / cobFile.h
blobbf8794e6852998da0107107db18213ac41130c4d
1 /*
2 * cobFile.h
3 * openc2e
5 * Created by Alyssa Milburn on Fri Jan 18 2008.
6 * Copyright (c) 2008 Alyssa Milburn. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
20 #ifndef COBFILE_H
21 #define COBFILE_H
23 #include <vector>
24 #include <string>
25 #include <fstream>
26 #include <boost/filesystem/path.hpp>
28 namespace fs = boost::filesystem;
30 class cobBlock;
32 class cobFile {
33 protected:
34 fs::path path;
35 std::ifstream file;
37 public:
38 std::vector<cobBlock *> blocks;
40 cobFile(fs::path filepath);
41 ~cobFile();
42 fs::path getPath() { return path; }
43 std::istream &getStream() { return file; }
46 class cobBlock {
47 protected:
48 bool loaded;
49 cobFile *parent;
50 unsigned char *buffer;
52 std::streampos offset;
53 unsigned int size;
55 public:
56 cobBlock(cobFile *p);
57 ~cobBlock();
58 void load();
59 void free();
61 std::string type;
63 bool isLoaded() { return loaded; }
64 cobFile *getParent() { return parent; }
65 std::streampos getOffset() { return offset; }
66 std::string getType() { return type; }
67 unsigned char *getBuffer() { assert(loaded); return buffer; }
68 unsigned int getSize() { return size; }
71 class cobAgentBlock {
72 protected:
73 cobBlock *parent;
75 public:
76 cobAgentBlock(cobBlock *p);
77 ~cobAgentBlock();
79 cobBlock *getParent() { return parent; }
81 unsigned short quantityremaining;
82 unsigned int lastusage;
83 unsigned int reuseinterval;
84 unsigned char usebyday;
85 unsigned char usebymonth;
86 unsigned short usebyyear;
88 std::string name;
89 std::string description;
90 std::string installscript;
91 std::string removescript;
92 std::vector<std::string> scripts;
94 std::vector<unsigned short> deptypes;
95 std::vector<std::string> depnames;
97 unsigned short thumbnailwidth;
98 unsigned short thumbnailheight;
99 unsigned short *thumbnail;
102 class cobFileBlock {
103 protected:
104 cobBlock *parent;
106 public:
107 cobFileBlock(cobBlock *p);
108 ~cobFileBlock();
110 cobBlock *getParent() { return parent; }
112 unsigned short filetype;
113 unsigned int filesize;
114 std::string filename;
115 unsigned char *getFileContents();
118 #endif
119 /* vim: set noet: */