Пример #1
0
		inode_tracker(const sp_obj& obj) {
			if(obj) {
				// if object doesn't have an inode then create one
				inode_ = obj->inode();
				if(!inode_) {
					inode_ = new blue_sky::bs_inode(obj);
					obj.lock()->inode_ = inode_;
				}
			}
		}
Пример #2
0
	//register instance of any BlueSky type
	int register_instance(const sp_obj& obj) {
		if(!obj) return 0;
		type_descriptor td = obj->bs_resolve_type();
		//go through chain of type_descriptors up to objbase
		int arity = 0;
		while(!td.is_nil()) {
			arity += instances_[td.type()].insert(obj).second;
			td = td.parent_td();
		}
		return arity;
	}
Пример #3
0
  void
  data_serializer::save (const sp_storage_t &storage, const sp_obj &obj) const
    {
      BS_ASSERT (storage);
      BS_ASSERT (obj);

      const sp_storage_t &locked_storage (storage);
      data_storage &st = *locked_storage;

      BS_ASSERT (false && "BASE METHOD CALL") (storage->bs_resolve_type ().stype_) (obj->bs_resolve_type ().stype_);
      st.save ("base method call", "---");
    }
Пример #4
0
  void
  data_storage_interface::save (const sp_obj &obj) const
    {
      // FIXME: Implement storage_
      if (!storage_)
        return ;

      BS_ASSERT (obj);
      const type_descriptor &td = obj->bs_resolve_type ();

      serializer_list_t::const_iterator it = serializer_list_->find (td.stype_);
      BS_ASSERT (it != serializer_list_->end ()) (td.stype_);

      if (it != serializer_list_->end ())
        it->second->save (storage_, obj);
    }
Пример #5
0
	int free_instance(const sp_obj& obj) {
		if(!obj) return 0;

		//if object is dangling, ie it's inode has zero hard links,
		//delete the inode (remove reference to obj)
		//if(obj->inode_ && obj->inode_->links_count() == 0)
		//	obj.lock()->inode_.release();

		//go through chain of type_descriptors up to objbase
		type_descriptor td = obj->bs_resolve_type();
		int arity = 0;
		while(!td.is_nil()) {
			arity += (int)instances_[td.type()].erase(obj);
			td = td.parent_td();
		}
		return arity;
	}
Пример #6
0
	sp_obj create_object_copy(const sp_obj& src, bool unmanaged) {
		if(!src) {
			throw bs_kernel_exception ("BlueSky kernel", no_error, "Source object for copying is not defined");
		}

		BS_TYPE_COPY_FUN cpyfn = *demand_type(src->bs_resolve_type()).td_.copy_fun_;
		BS_ERROR (cpyfn, "kernel::create_object_copy: copy_fun is null");

		// invoke copy creation function and make a smrt_ptr reference to new object
		sp_obj res((*cpyfn)(src), bs_dynamic_cast());
		if(res) {
			// if we successfully created an objbase instance
			// decrement reference counter
			res->del_ref();
			// register instance if needed
			if(!unmanaged) register_instance(res);
		}
		return res;
	}