1 # Copyright (c) 2018 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 """Module holding ClassifiedBitCountingMetadata class."""
16 from ClassifiedBitCountingMetadata import ClassifiedBitCountingMetadata
19 class ClassifiedMetadataFactory(object):
20 """Class for factory which adds classification to bit counting metadata."""
23 def with_classification(metadata, classification):
24 """Return new metadata object with added classification.
26 TODO: Is there a way to add classification to any metadata,
27 without messing up constructors and __repr__()?
29 FIXME: Factories take raw resources. Find a name for the thing
30 which takes semi-finished products. Transformer?
32 :param metadata: Existing metadata without classification.
33 :param classification: Arbitrary object classifying this group.
34 :type metadata: BitCountingMetadata
35 :type classification: object
36 :returns: The metadata with added classification.
37 :rtype: ClassifiedBitCountingMetadata
39 return ClassifiedBitCountingMetadata(
40 max_value=metadata.max_value, size=metadata.size, avg=metadata.avg,
41 stdev=metadata.stdev, prev_avg=metadata.prev_avg,
42 classification=classification)