aboutsummaryrefslogtreecommitdiffstats
path: root/meowpp/oo
diff options
context:
space:
mode:
authorcathook <b01902109@csie.ntu.edu.tw>2014-06-01 14:05:05 +0800
committercathook <b01902109@csie.ntu.edu.tw>2014-06-01 14:05:05 +0800
commit9ec5d78f273d306fb8793e73bbb658097439dbe2 (patch)
tree77c3e3d30f1010168252c70eed31afda5943b988 /meowpp/oo
parent0b0382ba2908791a3d372406da49cf681a35e2f8 (diff)
downloadmeow-9ec5d78f273d306fb8793e73bbb658097439dbe2.tar
meow-9ec5d78f273d306fb8793e73bbb658097439dbe2.tar.gz
meow-9ec5d78f273d306fb8793e73bbb658097439dbe2.tar.bz2
meow-9ec5d78f273d306fb8793e73bbb658097439dbe2.tar.lz
meow-9ec5d78f273d306fb8793e73bbb658097439dbe2.tar.xz
meow-9ec5d78f273d306fb8793e73bbb658097439dbe2.tar.zst
meow-9ec5d78f273d306fb8793e73bbb658097439dbe2.zip
remove hpp
Diffstat (limited to 'meowpp/oo')
-rw-r--r--meowpp/oo/ObjPort.hpp47
-rw-r--r--meowpp/oo/Properties.hpp175
2 files changed, 0 insertions, 222 deletions
diff --git a/meowpp/oo/ObjPort.hpp b/meowpp/oo/ObjPort.hpp
deleted file mode 100644
index d458adf..0000000
--- a/meowpp/oo/ObjPort.hpp
+++ /dev/null
@@ -1,47 +0,0 @@
-#include "ObjPort.h"
-
-#include "ObjSelector.h"
-#include "ObjBase.h"
-
-#include <cstdio>
-
-namespace meow{
- template<size_t sid>
- inline ObjPort::ObjBase* read(FILE* __f, bool __binary){
- char name[1024];
- unsigned int fg;
- if(__binary){
- size_t len;
- if(fread(&len, sizeof(size_t), 1, __f) < 1) return NULL;
- if(fread(name, sizeof(char), len, __f) < len) return NULL;
- if(fread(&fg, sizeof(unsigned int), 1, __f) < 1) return NULL;
- name[len] = '\0';
- }else{
- fscanf(__f, "%s %u", name, &fg);
- }
- ObjBase* ret = Selector<sid>(name);
- if(ret->read(__f, __binary, fg) == false){
- delete ret;
- ret = NULL;
- }
- return ret;
- }
-
-
- template<size_t sid>
- inline ObjPort::bool write(FILE* __f, bool __binary,
- ObjBase* __obj, unsigned int __fg){
- std::string name = Selector<sid>::find(__obj);
- if(__binary){
- size_t len = name.size();
- if(fwrite(&len, sizeof(size_t), 1, __f) < 1) return false;
- if(fwrite(name.c_str(), sizeof(char), len, __f) < len) return false;
- if(fwrite(&__fg, sizeof(unsigned int), 1, __f) < len) return false;
- }else{
- if(fprintf(__f, "%s %u\n", name.c_str(), __fg) < 2) return false;
- }
- return __obj->write(__f, __binary, __fg);
- }
-}
-
-#endif // oo_ObjPort_H__
diff --git a/meowpp/oo/Properties.hpp b/meowpp/oo/Properties.hpp
deleted file mode 100644
index 58be1b4..0000000
--- a/meowpp/oo/Properties.hpp
+++ /dev/null
@@ -1,175 +0,0 @@
-#include "Properties.h"
-
-#include "ObjBase.h"
-
-#include <map>
-#include <queue>
-
-
-namespace meow{
- inline Properties::Property::Property(ObjBase* __pointer, bool __autoRemove):
- _pointer(__pointer),
- _counter(__autoRemove ? -1 : 1){
- }
- inline Properties::Property::Property(Property const& __property):
- _pointer(__property._pointer),
- _counter(__property._counter){
- }
- inline Properties::Property::~Property(){
- }
- inline bool Properties::Property::attach(){
- if(_pointer == NULL || _counter <= 0) return false;
- _counter++;
- return true;
- }
- inline bool Properties::Property::detach(){
- if(_pointer == NULL || _counter <= 0) return false;
- _counter--;
- if(_counter <= 0){
- delete _pointer;
- _pointer = NULL;
- }
- return true;
- }
- ////////////////////////////////////////////////////////////////////
- inline size_t Properties::newIndex(std::string const& __name){
- size_t i;
- if(_freeIndex.size() > 0){
- i = _freeIndex.front();
- _freeIndex.pop();
- }else{
- i = size();
- }
- _index[__name] = i;
- return i;
- }
- inline void Properties::delIndex(size_t __index){
- _properties.erase(__index);
- for(std::map<std::string, size_t>::iterator it = _index.begin();
- it != _index.end();
- it++){
- if(it->second == __index){
- _index.erase(it);
- break;
- }
- }
- _freeIndex.push(__index);
- }
- inline void Properties::detach(size_t __index){
- _properties[__index]->detach();
- if(_properties[__index]->_counter == 0){
- delete _properties[__index];
- }
- _properties[__index] = NULL;
- }
- inline Properties::Properties(){
- }
- inline Properties::Properties(Properties const& __p){
- copy(__p);
- }
- inline Properties::~Properties(){
- clear();
- }
- inline void Properties::clear(){
- for(std::map<size_t, Property*>::iterator it = _properties.begin();
- it != _properties.end();
- it++){
- it->second->detach();
- }
- _properties.clear();
- _index .clear();
- while(!_freeIndex.empty())
- _freeIndex.pop();
- }
- inline Properties& Properties::copy(Properties const& __p){
- clear();
- _properties = ((Properties&)__p)._properties;
- _index = ((Properties&)__p)._index;
- _freeIndex = ((Properties&)__p)._freeIndex;
- for(std::map<size_t, Property*>::iterator it = _properties.begin();
- it != _properties.end();
- it++){
- it->second->attach();
- }
- return *this;
- }
- inline size_t Properties::size() const{
- return (_properties.size());
- }
- inline bool Properties::empty() const{
- return (size() == 0u);
- }
- inline bool Properties::chg(size_t __index,
- ObjBase* __pointer,
- bool __autoRemove){
- if(get(__index) == NULL)
- return false;
- detach(__index);
- _properties[__index] = new Property(__pointer, __autoRemove);
- return true;
- }
- inline bool Properties::add(std::string __name ,
- ObjBase* __pointer,
- bool __autoRemove){
- if(get(__name) != NULL)
- del(__name);
- _properties[newIndex(__name)] = new Property(__pointer, __autoRemove);
- return true;
- }
- inline bool Properties::del(size_t __index){
- if(get(__index) == NULL){
- return false;
- }
- detach(__index);
- delIndex(__index);
- return true;
- }
- inline bool Properties::del(std::string __name){
- if(get(__name) == NULL){
- return false;
- }
- return del(_index[__name]);
- }
- inline ObjBase* Properties::get(size_t __index) const{
- std::map<size_t, Property*>::const_iterator i = _properties.find(__index);
- if(i == _properties.end()) return NULL;
- return (ObjBase*)(i->second->_pointer);
- }
- inline ObjBase* Properties::get(std::string __name) const{
- std::map<std::string, size_t>::const_iterator i = _index.find(__name);
- if(i == _index.end()) return NULL;
- return get(i->second);
- }
- inline ssize_t Properties::getIndex(ObjBase* __pointer) const{
- for(std::map<size_t, Property*>::const_iterator it = _properties.begin();
- it != _properties.end();
- it++){
- if(it->second->_pointer == __pointer){
- return it->first;
- }
- }
- return -1;
- }
- inline std::string Properties::getName(ObjBase* __pointer) const{
- ssize_t t = getIndex(__pointer);
- if(t < 0) return std::string();
- for(std::map<std::string, size_t>::const_iterator it = _index.begin();
- it != _index.end();
- it++){
- if(it->second == (size_t)t){
- if(it == _index.end()) return std::string();
- return it->first;
- }
- }
- return std::string();
- }
- inline Properties& Properties::operator=(Properties const& __p){
- return copy(__p);
- }
- inline ObjBase* Properties::operator()(size_t __index) const{
- return get(__index);
- }
- inline ObjBase* Properties::operator()(std::string __name) const{
- return get(__name);
- }
-};