00001 /* 00002 * Copyright (c) 2000, 2020, Oracle and/or its affiliates. 00003 * 00004 * Licensed under the Universal Permissive License v 1.0 as shown at 00005 * http://oss.oracle.com/licenses/upl. 00006 */ 00007 #ifndef COH_UNIT_CALCULATOR_HPP 00008 #define COH_UNIT_CALCULATOR_HPP 00009 00010 #include "coherence/lang.ns" 00011 00012 COH_OPEN_NAMESPACE3(coherence,net,cache) 00013 00014 // ---- interface: UnitCalculator --------------------------------------- 00015 00016 /** 00017 * A unit calculator is an object that can calculate the cost of 00018 * caching an object. Used with LocalCache. 00019 * 00020 * @author nsa 2008.06.23 00021 */ 00022 class UnitCalculator 00023 : public interface_spec<UnitCalculator> 00024 { 00025 // ----- constants ------------------------------------------ 00026 00027 public: 00028 /** 00029 * The largest possible value of type size32_t. 00030 */ 00031 static const size32_t npos = size32_t(-1); 00032 00033 // ----- UnitCalculator interface --------------------------- 00034 00035 public: 00036 /** 00037 * Calculate a cache cost for the specified cache entry key 00038 * and value. 00039 * 00040 * @param vKey the cache key to evaluate for unit cost 00041 * @param vValue the cache value to evaluate for unit cost 00042 * 00043 * @return an integer value 0 or greater, with a larger value 00044 * signifying a higher cost 00045 */ 00046 virtual size32_t calculateUnits(Object::View vKey, 00047 Object::View vValue) const = 0; 00048 }; 00049 00050 COH_CLOSE_NAMESPACE3 00051 00052 #endif // #define COH_UNIT_CALCULATOR_HPP